<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/* base64x-1.1.34 (c) 2012-2023 Kenji Urushima | kjur.github.io/jsrsasign/license
<span class='line'>  2</span>  */</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="COMM">/*
<span class='line'>  4</span>  * base64x.js - Base64url and supplementary functions for Tom Wu's base64.js library
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * Copyright (c) 2012-2023 Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * This software is licensed under the terms of the MIT License.
<span class='line'>  9</span>  * https://kjur.github.io/jsrsasign/license
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * The above copyright and license notice shall be 
<span class='line'> 12</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 13</span>  */</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> </span><span class="COMM">/**
<span class='line'> 16</span>  * @fileOverview
<span class='line'> 17</span>  * @name base64x-1.1.js
<span class='line'> 18</span>  * @author Kenji Urushima kenji.urushima@gmail.com
<span class='line'> 19</span>  * @version jsrsasign 10.9.0 base64x 1.1.34 (2023-Nov-27)
<span class='line'> 20</span>  * @since jsrsasign 2.1
<span class='line'> 21</span>  * @license &lt;a href="https://kjur.github.io/jsrsasign/license/">MIT License&lt;/a>
<span class='line'> 22</span>  */</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR.lang</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR.lang</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR.lang</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 27</span> 
<span class='line'> 28</span> </span><span class="COMM">/**
<span class='line'> 29</span>  * String and its utility class &lt;br/>
<span class='line'> 30</span>  * This class provides some static utility methods for string.
<span class='line'> 31</span>  * @class String and its utility class
<span class='line'> 32</span>  * @author Kenji Urushima
<span class='line'> 33</span>  * @version 1.0 (2016-Aug-05)
<span class='line'> 34</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'> 35</span>  * @description
<span class='line'> 36</span>  * &lt;br/>
<span class='line'> 37</span>  * This class provides static methods for string utility.
<span class='line'> 38</span>  * &lt;dl>
<span class='line'> 39</span>  * &lt;dt>&lt;b>STRING TYPE CHECKERS&lt;/b>
<span class='line'> 40</span>  * &lt;dd>
<span class='line'> 41</span>  * &lt;ul>
<span class='line'> 42</span>  * &lt;li>{@link KJUR.lang.String.isInteger} - check whether argument is an integer&lt;/li>
<span class='line'> 43</span>  * &lt;li>{@link KJUR.lang.String.isHex} - check whether argument is a hexadecimal string&lt;/li>
<span class='line'> 44</span>  * &lt;li>{@link KJUR.lang.String.isBase64} - check whether argument is a Base64 encoded string&lt;/li>
<span class='line'> 45</span>  * &lt;li>{@link KJUR.lang.String.isBase64URL} - check whether argument is a Base64URL encoded string&lt;/li>
<span class='line'> 46</span>  * &lt;li>{@link KJUR.lang.String.isIntegerArray} - check whether argument is an array of integers&lt;/li>
<span class='line'> 47</span>  * &lt;li>{@link KJUR.lang.String.isPrintable} - check whether argument is PrintableString accepted characters&lt;/li>
<span class='line'> 48</span>  * &lt;li>{@link KJUR.lang.String.isIA5} - check whether argument is IA5String accepted characters&lt;/li>
<span class='line'> 49</span>  * &lt;li>{@link KJUR.lang.String.isMail} - check whether argument is RFC 822 e-mail address format&lt;/li>
<span class='line'> 50</span>  * &lt;/ul>
<span class='line'> 51</span>  * &lt;/dl>
<span class='line'> 52</span>  */</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="NAME">KJUR.lang.String</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span> 
<span class='line'> 55</span> </span><span class="COMM">/**
<span class='line'> 56</span>  * Base64URL and supplementary functions for Tom Wu's base64.js library.&lt;br/>
<span class='line'> 57</span>  * This class is just provide information about global functions
<span class='line'> 58</span>  * defined in 'base64x.js'. The 'base64x.js' script file provides
<span class='line'> 59</span>  * global functions for converting following data each other.
<span class='line'> 60</span>  * &lt;ul>
<span class='line'> 61</span>  * &lt;li>(ASCII) String&lt;/li>
<span class='line'> 62</span>  * &lt;li>UTF8 String including CJK, Latin and other characters&lt;/li>
<span class='line'> 63</span>  * &lt;li>byte array&lt;/li>
<span class='line'> 64</span>  * &lt;li>hexadecimal encoded String&lt;/li>
<span class='line'> 65</span>  * &lt;li>Full URIComponent encoded String (such like "%69%94")&lt;/li>
<span class='line'> 66</span>  * &lt;li>Base64 encoded String&lt;/li>
<span class='line'> 67</span>  * &lt;li>Base64URL encoded String&lt;/li>
<span class='line'> 68</span>  * &lt;/ul>
<span class='line'> 69</span>  * All functions in 'base64x.js' are defined in {@link global__} and not
<span class='line'> 70</span>  * in this class.
<span class='line'> 71</span>  * 
<span class='line'> 72</span>  * @class Base64URL and supplementary functions for Tom Wu's base64.js library
<span class='line'> 73</span>  * @author Kenji Urushima
<span class='line'> 74</span>  * @version 1.1 (07 May 2012)
<span class='line'> 75</span>  * @requires base64.js
<span class='line'> 76</span>  * @see &lt;a href="https://kjur.github.io/jsjws/">'jwjws'(JWS JavaScript Library) home page https://kjur.github.io/jsjws/&lt;/a>
<span class='line'> 77</span>  * @see &lt;a href="https://kjur.github.io/jsrsasigns/">'jwrsasign'(RSA Sign JavaScript Library) home page https://kjur.github.io/jsrsasign/&lt;/a>
<span class='line'> 78</span>  */</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Base64x</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 81</span> 
<span class='line'> 82</span> </span><span class="COMM">// ==== string / byte array ================================</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="COMM">/**
<span class='line'> 84</span>  * convert a string to an array of character codes
<span class='line'> 85</span>  * @name stoBA
<span class='line'> 86</span>  * @function
<span class='line'> 87</span>  * @param {String} s
<span class='line'> 88</span>  * @return {Array of Numbers} 
<span class='line'> 89</span>  */</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stoBA</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">	</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 97</span> 
<span class='line'> 98</span> </span><span class="COMM">/**
<span class='line'> 99</span>  * convert an array of character codes to a string
<span class='line'>100</span>  * @name BAtos
<span class='line'>101</span>  * @function
<span class='line'>102</span>  * @param {Array of Numbers} a array of character codes
<span class='line'>103</span>  * @return {String} s
<span class='line'>104</span>  */</span><span class="WHIT">
<span class='line'>105</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">BAtos</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>112</span> 
<span class='line'>113</span> </span><span class="COMM">// ==== byte array / hex ================================</span><span class="WHIT">
<span class='line'>114</span> </span><span class="COMM">/**
<span class='line'>115</span>  * convert an array of bytes(Number) to hexadecimal string.&lt;br/>
<span class='line'>116</span>  * @name BAtohex
<span class='line'>117</span>  * @function
<span class='line'>118</span>  * @param {Array of Numbers} a array of bytes
<span class='line'>119</span>  * @return {String} hexadecimal string
<span class='line'>120</span>  */</span><span class="WHIT">
<span class='line'>121</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">BAtohex</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hex1.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>130</span> 
<span class='line'>131</span> </span><span class="COMM">// ==== string / hex ================================</span><span class="WHIT">
<span class='line'>132</span> </span><span class="COMM">/**
<span class='line'>133</span>  * convert a ASCII string to a hexadecimal string of ASCII codes.&lt;br/>
<span class='line'>134</span>  * NOTE: This can't be used for non ASCII characters.
<span class='line'>135</span>  * @name stohex
<span class='line'>136</span>  * @function
<span class='line'>137</span>  * @param {s} s ASCII string
<span class='line'>138</span>  * @return {String} hexadecimal string
<span class='line'>139</span>  */</span><span class="WHIT">
<span class='line'>140</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">BAtohex</span><span class="PUNC">(</span><span class="NAME">stoBA</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>143</span> 
<span class='line'>144</span> </span><span class="COMM">// ==== string / base64 ================================</span><span class="WHIT">
<span class='line'>145</span> </span><span class="COMM">/**
<span class='line'>146</span>  * convert a ASCII string to a Base64 encoded string.&lt;br/>
<span class='line'>147</span>  * NOTE: This can't be used for non ASCII characters.
<span class='line'>148</span>  * @name stob64
<span class='line'>149</span>  * @function
<span class='line'>150</span>  * @param {s} s ASCII string
<span class='line'>151</span>  * @return {String} Base64 encoded string
<span class='line'>152</span>  */</span><span class="WHIT">
<span class='line'>153</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>156</span> 
<span class='line'>157</span> </span><span class="COMM">// ==== string / base64url ================================</span><span class="WHIT">
<span class='line'>158</span> </span><span class="COMM">/**
<span class='line'>159</span>  * convert a ASCII string to a Base64URL encoded string.&lt;br/>
<span class='line'>160</span>  * NOTE: This can't be used for non ASCII characters.
<span class='line'>161</span>  * @name stob64u
<span class='line'>162</span>  * @function
<span class='line'>163</span>  * @param {s} s ASCII string
<span class='line'>164</span>  * @return {String} Base64URL encoded string
<span class='line'>165</span>  */</span><span class="WHIT">
<span class='line'>166</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">stob64u</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>169</span> 
<span class='line'>170</span> </span><span class="COMM">/**
<span class='line'>171</span>  * convert a Base64URL encoded string to a ASCII string.&lt;br/>
<span class='line'>172</span>  * NOTE: This can't be used for Base64URL encoded non ASCII characters.
<span class='line'>173</span>  * @name b64utos
<span class='line'>174</span>  * @function
<span class='line'>175</span>  * @param {s} s Base64URL encoded string
<span class='line'>176</span>  * @return {String} ASCII string
<span class='line'>177</span>  */</span><span class="WHIT">
<span class='line'>178</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64utos</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">BAtos</span><span class="PUNC">(</span><span class="NAME">b64toBA</span><span class="PUNC">(</span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>181</span> 
<span class='line'>182</span> </span><span class="COMM">// ==== base64 / base64url ================================</span><span class="WHIT">
<span class='line'>183</span> </span><span class="COMM">/**
<span class='line'>184</span>  * convert a Base64 encoded string to a Base64URL encoded string.&lt;br/>
<span class='line'>185</span>  * @name b64tob64u
<span class='line'>186</span>  * @function
<span class='line'>187</span>  * @param {String} s Base64 encoded string
<span class='line'>188</span>  * @return {String} Base64URL encoded string
<span class='line'>189</span>  * @example
<span class='line'>190</span>  * b64tob64u("ab+c3f/==") &rarr; "ab-c3f_"
<span class='line'>191</span>  */</span><span class="WHIT">
<span class='line'>192</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\=/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"-"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\//g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"_"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>198</span> 
<span class='line'>199</span> </span><span class="COMM">/**
<span class='line'>200</span>  * convert a Base64URL encoded string to a Base64 encoded string.&lt;br/>
<span class='line'>201</span>  * @name b64utob64
<span class='line'>202</span>  * @function
<span class='line'>203</span>  * @param {String} s Base64URL encoded string
<span class='line'>204</span>  * @return {String} Base64 encoded string
<span class='line'>205</span>  * @example
<span class='line'>206</span>  * b64utob64("ab-c3f_") &rarr; "ab+c3f/=="
<span class='line'>207</span>  */</span><span class="WHIT">
<span class='line'>208</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"=="</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"="</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/-/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"+"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/_/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>214</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>215</span> 
<span class='line'>216</span> </span><span class="COMM">// ==== hex / base64url ================================</span><span class="WHIT">
<span class='line'>217</span> </span><span class="COMM">/**
<span class='line'>218</span>  * convert a hexadecimal string to a Base64URL encoded string.&lt;br/>
<span class='line'>219</span>  * @name hextob64u
<span class='line'>220</span>  * @function
<span class='line'>221</span>  * @param {String} s hexadecimal string
<span class='line'>222</span>  * @return {String} Base64URL encoded string
<span class='line'>223</span>  * @description
<span class='line'>224</span>  * convert a hexadecimal string to a Base64URL encoded string.
<span class='line'>225</span>  * NOTE: If leading "0" is omitted and odd number length for
<span class='line'>226</span>  * hexadecimal leading "0" is automatically added.
<span class='line'>227</span>  */</span><span class="WHIT">
<span class='line'>228</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextob64u</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>232</span> 
<span class='line'>233</span> </span><span class="COMM">/**
<span class='line'>234</span>  * convert a Base64URL encoded string to a hexadecimal string.&lt;br/>
<span class='line'>235</span>  * @name b64utohex
<span class='line'>236</span>  * @function
<span class='line'>237</span>  * @param {String} s Base64URL encoded string
<span class='line'>238</span>  * @return {String} hexadecimal string
<span class='line'>239</span>  */</span><span class="WHIT">
<span class='line'>240</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>243</span> 
<span class='line'>244</span> </span><span class="COMM">// ==== utf8 / base64url ================================</span><span class="WHIT">
<span class='line'>245</span> 
<span class='line'>246</span> </span><span class="COMM">/**
<span class='line'>247</span>  * convert a UTF-8 encoded string including CJK or Latin to a Base64URL encoded string.&lt;br/>
<span class='line'>248</span>  * @name utf8tob64u
<span class='line'>249</span>  * @function
<span class='line'>250</span>  * @param {String} s UTF-8 encoded string
<span class='line'>251</span>  * @return {String} Base64URL encoded string
<span class='line'>252</span>  * @since 1.1
<span class='line'>253</span>  * @example
<span class='line'>254</span>  * utf8tob64u("あ") &rarr; "44GC"
<span class='line'>255</span>  * utf8tob64u("aaa") &rarr; "YWFh"
<span class='line'>256</span>  */</span><span class="WHIT">
<span class='line'>257</span> 
<span class='line'>258</span> </span><span class="COMM">/**
<span class='line'>259</span>  * convert a Base64URL encoded string to a UTF-8 encoded string including CJK or Latin.&lt;br/>
<span class='line'>260</span>  * @name b64utoutf8
<span class='line'>261</span>  * @function
<span class='line'>262</span>  * @param {String} s Base64URL encoded string
<span class='line'>263</span>  * @return {String} UTF-8 encoded string
<span class='line'>264</span>  * @since 1.1
<span class='line'>265</span>  * @example
<span class='line'>266</span>  * b64utoutf8("44GC") &rarr; "あ"
<span class='line'>267</span>  * b64utoutf8("YWFh") &rarr; "aaa"
<span class='line'>268</span>  */</span><span class="WHIT">
<span class='line'>269</span> 
<span class='line'>270</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">utf8tob64u</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b64utoutf8</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> 
<span class='line'>272</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Buffer</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">  </span><span class="NAME">utf8tob64u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64tob64u</span><span class="PUNC">(</span><span class="NAME">Buffer.from</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'utf8'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="STRN">'base64'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> 
<span class='line'>277</span> </span><span class="WHIT">  </span><span class="NAME">b64utoutf8</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Buffer.from</span><span class="PUNC">(</span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'base64'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="STRN">'utf8'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">  </span><span class="NAME">utf8tob64u</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextob64u</span><span class="PUNC">(</span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>284</span> 
<span class='line'>285</span> </span><span class="WHIT">  </span><span class="NAME">b64utoutf8</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>289</span> 
<span class='line'>290</span> </span><span class="COMM">// ==== utf8 / base64url ================================</span><span class="WHIT">
<span class='line'>291</span> </span><span class="COMM">/**
<span class='line'>292</span>  * convert a UTF-8 encoded string including CJK or Latin to a Base64 encoded string.&lt;br/>
<span class='line'>293</span>  * @name utf8tob64
<span class='line'>294</span>  * @function
<span class='line'>295</span>  * @param {String} s UTF-8 encoded string
<span class='line'>296</span>  * @return {String} Base64 encoded string
<span class='line'>297</span>  * @since 1.1.1
<span class='line'>298</span>  */</span><span class="WHIT">
<span class='line'>299</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">utf8tob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>301</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>302</span> 
<span class='line'>303</span> </span><span class="COMM">/**
<span class='line'>304</span>  * convert a Base64 encoded string to a UTF-8 encoded string including CJK or Latin.&lt;br/>
<span class='line'>305</span>  * @name b64toutf8
<span class='line'>306</span>  * @function
<span class='line'>307</span>  * @param {String} s Base64 encoded string
<span class='line'>308</span>  * @return {String} UTF-8 encoded string
<span class='line'>309</span>  * @since 1.1.1
<span class='line'>310</span>  */</span><span class="WHIT">
<span class='line'>311</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64toutf8</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>314</span> 
<span class='line'>315</span> </span><span class="COMM">// ==== utf8 / hex ================================</span><span class="WHIT">
<span class='line'>316</span> </span><span class="COMM">/**
<span class='line'>317</span>  * convert a UTF-8 encoded string including CJK or Latin to a hexadecimal encoded string.&lt;br/>
<span class='line'>318</span>  * @name utf8tohex
<span class='line'>319</span>  * @function
<span class='line'>320</span>  * @param {String} s UTF-8 encoded string
<span class='line'>321</span>  * @return {String} hexadecimal encoded string
<span class='line'>322</span>  * @since 1.1.1
<span class='line'>323</span>  */</span><span class="WHIT">
<span class='line'>324</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">utf8tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>326</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>327</span> 
<span class='line'>328</span> </span><span class="COMM">/**
<span class='line'>329</span>  * convert a hexadecimal encoded string to a UTF-8 encoded string including CJK or Latin.&lt;br/>
<span class='line'>330</span>  * Note that when input is improper hexadecimal string as UTF-8 string, this function returns
<span class='line'>331</span>  * 'null'.
<span class='line'>332</span>  * @name hextoutf8
<span class='line'>333</span>  * @function
<span class='line'>334</span>  * @param {String} s hexadecimal encoded string
<span class='line'>335</span>  * @return {String} UTF-8 encoded string or null
<span class='line'>336</span>  * @since 1.1.1
<span class='line'>337</span>  */</span><span class="WHIT">
<span class='line'>338</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextoutf8</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">  </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>344</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>345</span> 
<span class='line'>346</span> </span><span class="COMM">// ==== iso8859-1 latin1 / utf8 ===================</span><span class="WHIT">
<span class='line'>347</span> </span><span class="COMM">/**
<span class='line'>348</span>  * convert a hexadecimal ISO 8859-1 latin string to UTF-8 string&lt;br/>
<span class='line'>349</span>  * @name iso88591hextoutf8
<span class='line'>350</span>  * @function
<span class='line'>351</span>  * @param {String} h hexadecimal ISO 8859-1 latin string
<span class='line'>352</span>  * @return {String} UTF-8 string
<span class='line'>353</span>  * @since jsrsasign 10.5.12 base64x 1.1.25
<span class='line'>354</span>  * @see utf8toiso88591hex
<span class='line'>355</span>  *
<span class='line'>356</span>  * @example
<span class='line'>357</span>  * iso88591hextoutf8("41a9fa") &rarr; "A©ú"
<span class='line'>358</span>  */</span><span class="WHIT">
<span class='line'>359</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">iso88591hextoutf8</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextoutf8</span><span class="PUNC">(</span><span class="NAME">iso88591hextoutf8hex</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>361</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>362</span> 
<span class='line'>363</span> </span><span class="COMM">/**
<span class='line'>364</span>  * convert UTF-8 string to a hexadecimal ISO 8859-1 latin string&lt;br/>
<span class='line'>365</span>  * @name utf8toiso88591hex
<span class='line'>366</span>  * @function
<span class='line'>367</span>  * @param {String} s hexadecimal ISO 8859-1 latin string
<span class='line'>368</span>  * @return {String} UTF-8 string
<span class='line'>369</span>  * @since jsrsasign 10.5.12 base64x 1.1.25
<span class='line'>370</span>  * @see iso88591hextoutf8
<span class='line'>371</span>  *
<span class='line'>372</span>  * @example
<span class='line'>373</span>  * utf8toiso88591hex("A©ú") &rarr; "41a9fa"
<span class='line'>374</span>  */</span><span class="WHIT">
<span class='line'>375</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">utf8toiso88591hex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">utf8hextoiso88591hex</span><span class="PUNC">(</span><span class="NAME">utf8tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>378</span> 
<span class='line'>379</span> </span><span class="COMM">/**
<span class='line'>380</span>  * convert a hexadecimal ISO 8859-1 latin string to UTF-8 hexadecimal string&lt;br/>
<span class='line'>381</span>  * @name iso88591hextoutf8hex
<span class='line'>382</span>  * @function
<span class='line'>383</span>  * @param {String} h hexadecimal ISO 8859-1 latin string
<span class='line'>384</span>  * @return {String} UTF-8 hexadecimal string
<span class='line'>385</span>  * @since jsrsasign 10.5.12 base64x 1.1.25
<span class='line'>386</span>  * @see iso88591hextoutf8
<span class='line'>387</span>  * @see utf8hextoiso88591hex
<span class='line'>388</span>  *
<span class='line'>389</span>  * @example
<span class='line'>390</span>  * iso88591hextoutf8hex("41a9fa") &rarr; "41c2a9c3ba"
<span class='line'>391</span>  */</span><span class="WHIT">
<span class='line'>392</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">iso88591hextoutf8hex</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.match</span><span class="PUNC">(</span><span class="REGX">/.{1,2}/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">0xa1</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">0xbf</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="STRN">"c2"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">0xc0</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">0xff</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="STRN">"c3"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a2.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>408</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>409</span> 
<span class='line'>410</span> </span><span class="COMM">/**
<span class='line'>411</span>  * convert UTF-8 string to a hexadecimal ISO 8859-1 latin string&lt;br/>
<span class='line'>412</span>  * @name utf8hextoiso88591hex
<span class='line'>413</span>  * @function
<span class='line'>414</span>  * @param {String} h hexadecimal UTF-8 string
<span class='line'>415</span>  * @return {String} hexadecimal ISO 8859-1 latin string
<span class='line'>416</span>  * @since jsrsasign 10.5.12 base64x 1.1.25
<span class='line'>417</span>  * @see iso88591hextoutf8hex
<span class='line'>418</span>  * @see utf8toiso88591hex
<span class='line'>419</span>  *
<span class='line'>420</span>  * @example
<span class='line'>421</span>  * utf8hextoiso88591hex("41c2a9c3ba") &rarr; "41a9fa"
<span class='line'>422</span>  */</span><span class="WHIT">
<span class='line'>423</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">utf8hextoiso88591hex</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.match</span><span class="PUNC">(</span><span class="REGX">/.{1,2}/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'c2'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">	    </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'c3'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT">	    </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ci</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">di</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="NAME">di.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">	    </span><span class="NAME">a2.push</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a2.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>440</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>441</span> 
<span class='line'>442</span> </span><span class="COMM">// ==== rstr / hex ================================</span><span class="WHIT">
<span class='line'>443</span> </span><span class="COMM">/**
<span class='line'>444</span>  * convert a hexadecimal encoded string to raw string including non printable characters.&lt;br/>
<span class='line'>445</span>  * @name hextorstr
<span class='line'>446</span>  * @function
<span class='line'>447</span>  * @param {String} s hexadecimal encoded string
<span class='line'>448</span>  * @return {String} raw string
<span class='line'>449</span>  * @since 1.1.2
<span class='line'>450</span>  * @example
<span class='line'>451</span>  * hextorstr("610061") &rarr; "a\x00a"
<span class='line'>452</span>  */</span><span class="WHIT">
<span class='line'>453</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextorstr</span><span class="PUNC">(</span><span class="NAME">sHex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">sHex.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">        </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">sHex.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>459</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>460</span> 
<span class='line'>461</span> </span><span class="COMM">/**
<span class='line'>462</span>  * convert a raw string including non printable characters to hexadecimal encoded string.&lt;br/>
<span class='line'>463</span>  * @name rstrtohex
<span class='line'>464</span>  * @function
<span class='line'>465</span>  * @param {String} s raw string
<span class='line'>466</span>  * @return {String} hexadecimal encoded string
<span class='line'>467</span>  * @since 1.1.2
<span class='line'>468</span>  * @example
<span class='line'>469</span>  * rstrtohex("a\x00a") &rarr; "610061"
<span class='line'>470</span>  */</span><span class="WHIT">
<span class='line'>471</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">rstrtohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">        </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>476</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>477</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>478</span> 
<span class='line'>479</span> </span><span class="COMM">// ==== hex / b64nl =======================================</span><span class="WHIT">
<span class='line'>480</span> 
<span class='line'>481</span> </span><span class="COMM">/**
<span class='line'>482</span>  * convert a hexadecimal string to Base64 encoded string&lt;br/>
<span class='line'>483</span>  * @name hextob64
<span class='line'>484</span>  * @function
<span class='line'>485</span>  * @param {String} s hexadecimal string
<span class='line'>486</span>  * @return {String} resulted Base64 encoded string
<span class='line'>487</span>  * @since base64x 1.1.3
<span class='line'>488</span>  * @description
<span class='line'>489</span>  * This function converts from a hexadecimal string to Base64 encoded
<span class='line'>490</span>  * string without new lines.
<span class='line'>491</span>  * @example
<span class='line'>492</span>  * hextob64("616161") &rarr; "YWFh"
<span class='line'>493</span>  */</span><span class="WHIT">
<span class='line'>494</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex2b64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>496</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>497</span> 
<span class='line'>498</span> </span><span class="COMM">/**
<span class='line'>499</span>  * convert a hexadecimal string to Base64 encoded string with new lines&lt;br/>
<span class='line'>500</span>  * @name hextob64nl
<span class='line'>501</span>  * @function
<span class='line'>502</span>  * @param {String} s hexadecimal string
<span class='line'>503</span>  * @return {String} resulted Base64 encoded string with new lines
<span class='line'>504</span>  * @since base64x 1.1.3
<span class='line'>505</span>  * @description
<span class='line'>506</span>  * This function converts from a hexadecimal string to Base64 encoded
<span class='line'>507</span>  * string with new lines for each 64 characters. This is useful for
<span class='line'>508</span>  * PEM encoded file.
<span class='line'>509</span>  * @example
<span class='line'>510</span>  * hextob64nl("123456789012345678901234567890123456789012345678901234567890")
<span class='line'>511</span>  * &rarr;
<span class='line'>512</span>  * MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4 // new line
<span class='line'>513</span>  * OTAxMjM0NTY3ODkwCg==
<span class='line'>514</span>  */</span><span class="WHIT">
<span class='line'>515</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextob64nl</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">foldnl</span><span class="PUNC">(</span><span class="NAME">hextob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>517</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>518</span> 
<span class='line'>519</span> </span><span class="COMM">/**
<span class='line'>520</span>  * wrap string with new lines to fit in specified width&lt;br/>
<span class='line'>521</span>  * @name foldnl
<span class='line'>522</span>  * @function
<span class='line'>523</span>  * @param {string} s string
<span class='line'>524</span>  * @param {number} n width
<span class='line'>525</span>  * @return {string} wrapped string with new lines
<span class='line'>526</span>  * @since jsrsasign 10.7.0 base64x 1.1.31
<span class='line'>527</span>  * @description
<span class='line'>528</span>  * This function wrap a string with new lines to fit in specified width.
<span class='line'>529</span>  * @example
<span class='line'>530</span>  * foldnl("1234567890", 6)
<span class='line'>531</span>  * &rarr;
<span class='line'>532</span>  * 123456
<span class='line'>533</span>  * 7890
<span class='line'>534</span>  */</span><span class="WHIT">
<span class='line'>535</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">foldnl</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'(.{'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'})'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'g'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"$1\r\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\s+$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>539</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>540</span> 
<span class='line'>541</span> </span><span class="COMM">/**
<span class='line'>542</span>  * convert a Base64 encoded string with new lines to a hexadecimal string&lt;br/>
<span class='line'>543</span>  * @name b64nltohex
<span class='line'>544</span>  * @function
<span class='line'>545</span>  * @param {String} s Base64 encoded string with new lines
<span class='line'>546</span>  * @return {String} hexadecimal string
<span class='line'>547</span>  * @since base64x 1.1.3
<span class='line'>548</span>  * @description
<span class='line'>549</span>  * This function converts from a Base64 encoded
<span class='line'>550</span>  * string with new lines to a hexadecimal string.
<span class='line'>551</span>  * This is useful to handle PEM encoded file.
<span class='line'>552</span>  * This function removes any non-Base64 characters (i.e. not 0-9,A-Z,a-z,\,+,=)
<span class='line'>553</span>  * including new line.
<span class='line'>554</span>  * @example
<span class='line'>555</span>  * hextob64nl(
<span class='line'>556</span>  * "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4\r\n" +
<span class='line'>557</span>  * "OTAxMjM0NTY3ODkwCg==\r\n")
<span class='line'>558</span>  * &rarr;
<span class='line'>559</span>  * "123456789012345678901234567890123456789012345678901234567890"
<span class='line'>560</span>  */</span><span class="WHIT">
<span class='line'>561</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64nltohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b64</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/[^0-9A-Za-z\/+=]*/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64tohex</span><span class="PUNC">(</span><span class="NAME">b64</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>565</span> </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>566</span> 
<span class='line'>567</span> </span><span class="COMM">// ==== b64 / pem =========================================</span><span class="WHIT">
<span class='line'>568</span> </span><span class="COMM">/**
<span class='line'>569</span>  * get PEM string from Base64 string
<span class='line'>570</span>  * @name b64topem
<span class='line'>571</span>  * @function
<span class='line'>572</span>  * @param {string} b64 Base64 string of PEM body
<span class='line'>573</span>  * @param {string} pemHeader PEM header string (ex. 'RSA PRIVATE KEY')
<span class='line'>574</span>  * @return {string} PEM formatted string of input data
<span class='line'>575</span>  * @since jsrasign 10.7.0 base64x 1.1.31
<span class='line'>576</span>  * @description
<span class='line'>577</span>  * This function converts a Base64 string to a PEM string with
<span class='line'>578</span>  * a specified header. Its line break will be CRLF("\r\n").
<span class='line'>579</span>  * @example
<span class='line'>580</span>  * b64topem('YWFh', 'RSA PRIVATE KEY') &rarr;
<span class='line'>581</span>  * -----BEGIN PRIVATE KEY-----
<span class='line'>582</span>  * YWFh
<span class='line'>583</span>  * -----END PRIVATE KEY-----
<span class='line'>584</span>  */</span><span class="WHIT">
<span class='line'>585</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">b64topem</span><span class="PUNC">(</span><span class="NAME">b64</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pemHeader</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>586</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"-----BEGIN "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pemHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-----\r\n"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>587</span> 	</span><span class="NAME">foldnl</span><span class="PUNC">(</span><span class="NAME">b64</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">        </span><span class="STRN">"\r\n-----END "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pemHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-----\r\n"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>589</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>590</span> 
<span class='line'>591</span> 
<span class='line'>592</span> 
<span class='line'>593</span> </span><span class="COMM">// ==== hex / pem =========================================</span><span class="WHIT">
<span class='line'>594</span> 
<span class='line'>595</span> </span><span class="COMM">/**
<span class='line'>596</span>  * get PEM string from hexadecimal data and header string
<span class='line'>597</span>  * @name hextopem
<span class='line'>598</span>  * @function
<span class='line'>599</span>  * @param {String} dataHex hexadecimal string of PEM body
<span class='line'>600</span>  * @param {String} pemHeader PEM header string (ex. 'RSA PRIVATE KEY')
<span class='line'>601</span>  * @return {String} PEM formatted string of input data
<span class='line'>602</span>  * @since jsrasign 7.2.1 base64x 1.1.12
<span class='line'>603</span>  * @description
<span class='line'>604</span>  * This function converts a hexadecimal string to a PEM string with
<span class='line'>605</span>  * a specified header. Its line break will be CRLF("\r\n").
<span class='line'>606</span>  * @example
<span class='line'>607</span>  * hextopem('616161', 'RSA PRIVATE KEY') &rarr;
<span class='line'>608</span>  * -----BEGIN PRIVATE KEY-----
<span class='line'>609</span>  * YWFh
<span class='line'>610</span>  * -----END PRIVATE KEY-----
<span class='line'>611</span>  */</span><span class="WHIT">
<span class='line'>612</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextopem</span><span class="PUNC">(</span><span class="NAME">dataHex</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pemHeader</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"-----BEGIN "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pemHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-----\r\n"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>614</span> 	</span><span class="NAME">foldnl</span><span class="PUNC">(</span><span class="NAME">hextob64</span><span class="PUNC">(</span><span class="NAME">dataHex</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>615</span> </span><span class="WHIT">        </span><span class="STRN">"\r\n-----END "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pemHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"-----\r\n"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>616</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>617</span> 
<span class='line'>618</span> </span><span class="COMM">/**
<span class='line'>619</span>  * get hexacedimal string from PEM format data&lt;br/>
<span class='line'>620</span>  * @name pemtohex
<span class='line'>621</span>  * @function
<span class='line'>622</span>  * @param {String} s PEM formatted string
<span class='line'>623</span>  * @param {String} sHead PEM header string without BEGIN/END(OPTION)
<span class='line'>624</span>  * @return {String} hexadecimal string data of PEM contents
<span class='line'>625</span>  * @since jsrsasign 7.2.1 base64x 1.1.12
<span class='line'>626</span>  *
<span class='line'>627</span>  * @description
<span class='line'>628</span>  * This static method gets a hexacedimal string of contents 
<span class='line'>629</span>  * from PEM format data. You can explicitly specify PEM header 
<span class='line'>630</span>  * by sHead argument. 
<span class='line'>631</span>  * Any space characters such as white space or new line
<span class='line'>632</span>  * will be omitted.&lt;br/>
<span class='line'>633</span>  * NOTE: Now {@link KEYUTIL.getHexFromPEM} and {@link X509.pemToHex}
<span class='line'>634</span>  * have been deprecated since jsrsasign 7.2.1. &lt;br/>
<span class='line'>635</span>  * Please use this method instead.
<span class='line'>636</span>  * NOTE2: From jsrsasign 8.0.14 this can process multi
<span class='line'>637</span>  * "BEGIN...END" section such as "EC PRIVATE KEY" with "EC PARAMETERS".&lt;br/>
<span class='line'>638</span>  *
<span class='line'>639</span>  * @example
<span class='line'>640</span>  * pemtohex("-----BEGIN PUBLIC KEY...") &rarr; "3082..."
<span class='line'>641</span>  * pemtohex("-----BEGIN CERTIFICATE...", "CERTIFICATE") &rarr; "3082..."
<span class='line'>642</span>  * pemtohex(" \r\n-----BEGIN DSA PRIVATE KEY...") &rarr; "3082..."
<span class='line'>643</span>  * pemtohex("-----BEGIN EC PARAMETERS...----BEGIN EC PRIVATE KEY...." &rarr; "3082..."
<span class='line'>644</span>  */</span><span class="WHIT">
<span class='line'>645</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">pemtohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sHead</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>646</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.indexOf</span><span class="PUNC">(</span><span class="STRN">"-----BEGIN "</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>647</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"can't find PEM header"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>648</span> 
<span class='line'>649</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sHead</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>650</span> </span><span class="WHIT">        </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'^[^]*-----BEGIN '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sHead</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-----'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>651</span> </span><span class="WHIT">        </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">RegExp</span><span class="PUNC">(</span><span class="STRN">'-----END '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sHead</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-----[^]*$'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>652</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>653</span> </span><span class="WHIT">        </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/^[^]*-----BEGIN [^-]+-----/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>654</span> </span><span class="WHIT">        </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/-----END [^-]+-----[^]*$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>655</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>656</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">b64nltohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>657</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>658</span> 
<span class='line'>659</span> </span><span class="COMM">/**
<span class='line'>660</span>  * get Base64 string from PEM format data&lt;br/>
<span class='line'>661</span>  * @name pemtob64
<span class='line'>662</span>  * @function
<span class='line'>663</span>  * @param {string} s PEM formatted string
<span class='line'>664</span>  * @return {string} Base64 string or null
<span class='line'>665</span>  * @since jsrsasign 10.7.0 base64x 1.1.31
<span class='line'>666</span>  *
<span class='line'>667</span>  * @description
<span class='line'>668</span>  * This static method gets a Base64 string of contents 
<span class='line'>669</span>  * from PEM format data.
<span class='line'>670</span>  * When s is not PEM data, it returns null.
<span class='line'>671</span>  *
<span class='line'>672</span>  * @example
<span class='line'>673</span>  * pemtohex("-----BEGIN CERTIFICATE...", "CERTIFICATE") &rarr; "MIIBvTCC..."
<span class='line'>674</span>  */</span><span class="WHIT">
<span class='line'>675</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">pemtob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.indexOf</span><span class="PUNC">(</span><span class="STRN">"-----BEGIN "</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT">        </span><span class="NAME">s.indexOf</span><span class="PUNC">(</span><span class="STRN">"-----END "</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/^[\s\S]*?-----BEGIN [^-]+-----/m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/-----END [\s\S]+$/m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>681</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-zA-Z+/</span><span class="PUNC">=</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="NAME">$</span><span class="PUNC">/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>682</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>683</span> 
<span class='line'>684</span> </span><span class="COMM">// ==== hex / ArrayBuffer =================================</span><span class="WHIT">
<span class='line'>685</span> 
<span class='line'>686</span> </span><span class="COMM">/**
<span class='line'>687</span>  * convert a hexadecimal string to an ArrayBuffer&lt;br/>
<span class='line'>688</span>  * @name hextoArrayBuffer
<span class='line'>689</span>  * @function
<span class='line'>690</span>  * @param {String} hex hexadecimal string
<span class='line'>691</span>  * @return {ArrayBuffer} ArrayBuffer
<span class='line'>692</span>  * @since jsrsasign 6.1.4 base64x 1.1.8
<span class='line'>693</span>  * @description
<span class='line'>694</span>  * This function converts from a hexadecimal string to an ArrayBuffer.
<span class='line'>695</span>  * @example
<span class='line'>696</span>  * hextoArrayBuffer("fffa01") &rarr; ArrayBuffer of [255, 250, 1]
<span class='line'>697</span>  */</span><span class="WHIT">
<span class='line'>698</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextoArrayBuffer</span><span class="PUNC">(</span><span class="NAME">hex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>699</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hex.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"input is not even length"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>700</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hex.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Fa-f]+$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"input is not hexadecimal"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>701</span> 
<span class='line'>702</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">buffer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ArrayBuffer</span><span class="PUNC">(</span><span class="NAME">hex.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>703</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">view</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">DataView</span><span class="PUNC">(</span><span class="NAME">buffer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>704</span> 
<span class='line'>705</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">hex.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT">	</span><span class="NAME">view.setUint8</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">hex.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>708</span> 
<span class='line'>709</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">buffer</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>710</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>711</span> 
<span class='line'>712</span> </span><span class="COMM">// ==== ArrayBuffer / hex =================================</span><span class="WHIT">
<span class='line'>713</span> 
<span class='line'>714</span> </span><span class="COMM">/**
<span class='line'>715</span>  * convert an ArrayBuffer to a hexadecimal string&lt;br/>
<span class='line'>716</span>  * @name ArrayBuffertohex
<span class='line'>717</span>  * @function
<span class='line'>718</span>  * @param {ArrayBuffer} buffer ArrayBuffer
<span class='line'>719</span>  * @return {String} hexadecimal string
<span class='line'>720</span>  * @since jsrsasign 6.1.4 base64x 1.1.8
<span class='line'>721</span>  * @description
<span class='line'>722</span>  * This function converts from an ArrayBuffer to a hexadecimal string.
<span class='line'>723</span>  * @example
<span class='line'>724</span>  * var buffer = new ArrayBuffer(3);
<span class='line'>725</span>  * var view = new DataView(buffer);
<span class='line'>726</span>  * view.setUint8(0, 0xfa);
<span class='line'>727</span>  * view.setUint8(1, 0xfb);
<span class='line'>728</span>  * view.setUint8(2, 0x01);
<span class='line'>729</span>  * ArrayBuffertohex(buffer) &rarr; "fafb01"
<span class='line'>730</span>  */</span><span class="WHIT">
<span class='line'>731</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ArrayBuffertohex</span><span class="PUNC">(</span><span class="NAME">buffer</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">view</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">DataView</span><span class="PUNC">(</span><span class="NAME">buffer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>734</span> 
<span class='line'>735</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">buffer.byteLength</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT">	</span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">view.getUint8</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>738</span> 
<span class='line'>739</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>741</span> 
<span class='line'>742</span> </span><span class="COMM">// ==== zulu / int =================================</span><span class="WHIT">
<span class='line'>743</span> </span><span class="COMM">/**
<span class='line'>744</span>  * GeneralizedTime or UTCTime string to milliseconds from Unix origin&lt;br>
<span class='line'>745</span>  * @name zulutomsec
<span class='line'>746</span>  * @function
<span class='line'>747</span>  * @param {String} s GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
<span class='line'>748</span>  * @return {Number} milliseconds from Unix origin time (i.e. Jan 1, 1970 0:00:00 UTC)
<span class='line'>749</span>  * @since jsrsasign 7.1.3 base64x 1.1.9
<span class='line'>750</span>  * @description
<span class='line'>751</span>  * This function converts from GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or
<span class='line'>752</span>  * UTCTime string (i.e. YYMMDDHHmmSSZ) to milliseconds from Unix origin time
<span class='line'>753</span>  * (i.e. Jan 1 1970 0:00:00 UTC). 
<span class='line'>754</span>  * Argument string may have fraction of seconds and
<span class='line'>755</span>  * its length is one or more digits such as "20170410235959.1234567Z".
<span class='line'>756</span>  * As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY.
<span class='line'>757</span>  * If year "YY" is equal or greater than 50 then it is 19YY.
<span class='line'>758</span>  * @example
<span class='line'>759</span>  * zulutomsec(  "071231235959Z")       &rarr; 1199145599000 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>760</span>  * zulutomsec(  "071231235959.1Z")     &rarr; 1199145599100 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>761</span>  * zulutomsec(  "071231235959.12345Z") &rarr; 1199145599123 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>762</span>  * zulutomsec("20071231235959Z")       &rarr; 1199145599000 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>763</span>  * zulutomsec(  "931231235959Z")       &rarr; -410227201000 #Mon, 31 Dec 1956 23:59:59 GMT
<span class='line'>764</span>  */</span><span class="WHIT">
<span class='line'>765</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">zulutomsec</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">year</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">day</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">msec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sYear</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sFrac</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sMsec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>768</span> 
<span class='line'>769</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">timetogen</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">    </span><span class="NAME">matchResult</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>771</span> 
<span class='line'>772</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT">	</span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>774</span> </span><span class="WHIT">	</span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT">	</span><span class="NAME">day</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">	</span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">4</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">	</span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">5</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">	</span><span class="NAME">sec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">6</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT">	</span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>780</span> 
<span class='line'>781</span> </span><span class="WHIT">	</span><span class="NAME">sFrac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">7</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sFrac</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT">	    </span><span class="NAME">sMsec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sFrac.substr</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// .12 -> 012</span><span class="WHIT">
<span class='line'>784</span> </span><span class="WHIT">	    </span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">sMsec</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>785</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>786</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Date.UTC</span><span class="PUNC">(</span><span class="NAME">year</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">day</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">min</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">msec</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>787</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>788</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"unsupported zulu format: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>789</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>790</span> 
<span class='line'>791</span> </span><span class="COMM">/**
<span class='line'>792</span>  * Unix origin milliseconds GeneralizedTime string&lt;br>
<span class='line'>793</span>  * @name msectozulu
<span class='line'>794</span>  * @function
<span class='line'>795</span>  * @param {number} n milliseconds from Unix origin time (i.e. Jan 1, 1970 0:00:00 UTC)
<span class='line'>796</span>  * @return {string} GeneralizedTime string (ex. 20170412235959.384Z)
<span class='line'>797</span>  * @since jsrsasign 10.8.0 base64x 1.1.31
<span class='line'>798</span>  *
<span class='line'>799</span>  * @description
<span class='line'>800</span>  * This function converts from milliseconds of Unix origin time (ex. 1199145599000
<span class='line'>801</span>  * for 31 Dec 2007 23:59:59 GMT) to GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ).
<span class='line'>802</span>  * The result string may have a fraction of second.
<span class='line'>803</span>  *
<span class='line'>804</span>  * @example
<span class='line'>805</span>  * msectozulu(1199145599000) &rarr; "20071231235959Z"       #Mon, 31 Dec 2007 23:59:59     GMT
<span class='line'>806</span>  * msectozulu(1199145599100) &rarr; "20071231235959.1Z"     #Mon, 31 Dec 2007 23:59:59.1   GMT
<span class='line'>807</span>  * msectozulu(1199145599123) &rarr; "20071231235959.123Z"   #Mon, 31 Dec 2007 23:59:59.123 GMT
<span class='line'>808</span>  */</span><span class="WHIT">
<span class='line'>809</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">msectozulu</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>810</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT">        </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">        </span><span class="NAME">mon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">        </span><span class="NAME">day</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT">        </span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">        </span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">        </span><span class="NAME">sec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT">	</span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCMilliseconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>818</span> </span><span class="WHIT">    </span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">msec.replace</span><span class="PUNC">(</span><span class="REGX">/0+$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">    </span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">msec</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">mon</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">day</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sec</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">msec</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"Z"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>821</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>822</span> 
<span class='line'>823</span> </span><span class="COMM">/**
<span class='line'>824</span>  * GeneralizedTime or UTCTime string to seconds from Unix origin&lt;br>
<span class='line'>825</span>  * @name zulutosec
<span class='line'>826</span>  * @function
<span class='line'>827</span>  * @param {String} s GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
<span class='line'>828</span>  * @return {Number} seconds from Unix origin time (i.e. Jan 1, 1970 0:00:00 UTC)
<span class='line'>829</span>  * @since jsrsasign 7.1.3 base64x 1.1.9
<span class='line'>830</span>  * @description
<span class='line'>831</span>  * This function converts from GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or
<span class='line'>832</span>  * UTCTime string (i.e. YYMMDDHHmmSSZ) to seconds from Unix origin time
<span class='line'>833</span>  * (i.e. Jan 1 1970 0:00:00 UTC). Argument string may have fraction of seconds 
<span class='line'>834</span>  * however result value will be omitted.
<span class='line'>835</span>  * As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY.
<span class='line'>836</span>  * If year "YY" is equal or greater than 50 then it is 19YY.
<span class='line'>837</span>  * @example
<span class='line'>838</span>  * zulutosec(  "071231235959Z")       &rarr; 1199145599 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>839</span>  * zulutosec(  "071231235959.1Z")     &rarr; 1199145599 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>840</span>  * zulutosec("20071231235959Z")       &rarr; 1199145599 #Mon, 31 Dec 2007 23:59:59 GMT
<span class='line'>841</span>  */</span><span class="WHIT">
<span class='line'>842</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">zulutosec</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">zulutomsec</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">1000.0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>844</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>845</span> 
<span class='line'>846</span> </span><span class="COMM">// ==== zulu / Date =================================</span><span class="WHIT">
<span class='line'>847</span> 
<span class='line'>848</span> </span><span class="COMM">/**
<span class='line'>849</span>  * GeneralizedTime or UTCTime string to Date object&lt;br>
<span class='line'>850</span>  * @name zulutodate
<span class='line'>851</span>  * @function
<span class='line'>852</span>  * @param {String} s GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
<span class='line'>853</span>  * @return {Date} Date object for specified time
<span class='line'>854</span>  * @since jsrsasign 7.1.3 base64x 1.1.9
<span class='line'>855</span>  * @description
<span class='line'>856</span>  * This function converts from GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or
<span class='line'>857</span>  * UTCTime string (i.e. YYMMDDHHmmSSZ) to Date object.
<span class='line'>858</span>  * Argument string may have fraction of seconds and
<span class='line'>859</span>  * its length is one or more digits such as "20170410235959.1234567Z".
<span class='line'>860</span>  * As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY.
<span class='line'>861</span>  * If year "YY" is equal or greater than 50 then it is 19YY.
<span class='line'>862</span>  * @example
<span class='line'>863</span>  * zulutodate(  "071231235959Z").toUTCString()   &rarr; "Mon, 31 Dec 2007 23:59:59 GMT"
<span class='line'>864</span>  * zulutodate(  "071231235959.1Z").toUTCString() &rarr; "Mon, 31 Dec 2007 23:59:59 GMT"
<span class='line'>865</span>  * zulutodate("20071231235959Z").toUTCString()   &rarr; "Mon, 31 Dec 2007 23:59:59 GMT"
<span class='line'>866</span>  * zulutodate(  "071231235959.34").getMilliseconds() &rarr; 340
<span class='line'>867</span>  */</span><span class="WHIT">
<span class='line'>868</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">zulutodate</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>869</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">zulutomsec</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>870</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>871</span> 
<span class='line'>872</span> </span><span class="COMM">/**
<span class='line'>873</span>  * Date object to zulu time string&lt;br>
<span class='line'>874</span>  * @name datetozulu
<span class='line'>875</span>  * @function
<span class='line'>876</span>  * @param {Date} d Date object for specified time
<span class='line'>877</span>  * @param {Boolean} flagUTCTime if this is true year will be YY otherwise YYYY
<span class='line'>878</span>  * @param {Boolean} flagMilli if this is true result concludes milliseconds
<span class='line'>879</span>  * @return {String} GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
<span class='line'>880</span>  * @since jsrsasign 7.2.0 base64x 1.1.11
<span class='line'>881</span>  * @description
<span class='line'>882</span>  * This function converts from Date object to GeneralizedTime string (i.e. YYYYMMDDHHmmSSZ) or
<span class='line'>883</span>  * UTCTime string (i.e. YYMMDDHHmmSSZ).
<span class='line'>884</span>  * As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY.
<span class='line'>885</span>  * If year "YY" is equal or greater than 50 then it is 19YY.
<span class='line'>886</span>  * If flagMilli is true its result concludes milliseconds such like
<span class='line'>887</span>  * "20170520235959.42Z". 
<span class='line'>888</span>  * @example
<span class='line'>889</span>  * d = new Date(Date.UTC(2017,4,20,23,59,59,670));
<span class='line'>890</span>  * datetozulu(d) &rarr; "20170520235959Z"
<span class='line'>891</span>  * datetozulu(d, true) &rarr; "170520235959Z"
<span class='line'>892</span>  * datetozulu(d, false, true) &rarr; "20170520235959.67Z"
<span class='line'>893</span>  */</span><span class="WHIT">
<span class='line'>894</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">datetozulu</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flagUTCTime</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flagMilli</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>896</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>897</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flagUTCTime</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>898</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">1950</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">2049</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">year</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>899</span> 	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"not proper year for UTCTime: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">year</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>900</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">""</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">year</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>902</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">year</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>903</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>904</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>905</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>906</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>907</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>908</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>909</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flagMilli</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>910</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">milli</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCMilliseconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>911</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">milli</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>912</span> </span><span class="WHIT">	    </span><span class="NAME">milli</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">milli</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT">	    </span><span class="NAME">milli</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">milli.replace</span><span class="PUNC">(</span><span class="REGX">/0+$/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>914</span> </span><span class="WHIT">	    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">milli</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>915</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>916</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>917</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"Z"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>918</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>919</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>920</span> 
<span class='line'>921</span> </span><span class="COMM">/**
<span class='line'>922</span>  * GeneralizedTime or UTCTime string to GeneralizedTime&lt;br>
<span class='line'>923</span>  * @name timetogen
<span class='line'>924</span>  * @function
<span class='line'>925</span>  * @param {string} s GeneralizedTime or UTCTime string (ex. 20170412235959.384Z)
<span class='line'>926</span>  * @return {string} GeneralizedTime
<span class='line'>927</span>  * @since jsrsasign 10.7.0 base64x 1.1.31
<span class='line'>928</span>  * @description
<span class='line'>929</span>  * This function converts UTCTime string (i.e. YYMMDDHHmmSSZ ) to 
<span class='line'>930</span>  * GeneralizedTime (YYYYMMDDHHmmSSZ) when the argument 's' is UTCTime. 
<span class='line'>931</span>  * Argument string may have fraction of seconds and
<span class='line'>932</span>  * its length is one or more digits such as "170410235959.1234567Z".
<span class='line'>933</span>  * As for UTCTime, if year "YY" is equal or less than 49 then it is 20YY.
<span class='line'>934</span>  * If year "YY" is equal or greater than 50 then it is 19YY.
<span class='line'>935</span>  * @example
<span class='line'>936</span>  * timetogen(  "071231235959Z") &rarr; "20071231235959Z"
<span class='line'>937</span>  * timetogen(  "971231235959Z") &rarr; "19971231235959Z"
<span class='line'>938</span>  * timetogen("20071231235959Z") &rarr; "20071231235959Z"
<span class='line'>939</span>  * timetogen(  "971231235959.123Z") &rarr; "19971231235959.123Z"
<span class='line'>940</span>  */</span><span class="WHIT">
<span class='line'>941</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">timetogen</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>942</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9]{12}Z$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9]{12}[.][0-9]*Z$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-4]/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"20"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"19"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>944</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>945</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>946</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>947</span> 
<span class='line'>948</span> </span><span class="COMM">// ==== URIComponent / hex ================================</span><span class="WHIT">
<span class='line'>949</span> </span><span class="COMM">/**
<span class='line'>950</span>  * convert a URLComponent string such like "%67%68" to a hexadecimal string.&lt;br/>
<span class='line'>951</span>  * @name uricmptohex
<span class='line'>952</span>  * @function
<span class='line'>953</span>  * @param {String} s URIComponent string such like "%67%68"
<span class='line'>954</span>  * @return {String} hexadecimal string
<span class='line'>955</span>  * @since 1.1
<span class='line'>956</span>  */</span><span class="WHIT">
<span class='line'>957</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">uricmptohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>958</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/%/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>959</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>960</span> 
<span class='line'>961</span> </span><span class="COMM">/**
<span class='line'>962</span>  * convert a hexadecimal string to a URLComponent string such like "%67%68".&lt;br/>
<span class='line'>963</span>  * @name hextouricmp
<span class='line'>964</span>  * @function
<span class='line'>965</span>  * @param {String} s hexadecimal string
<span class='line'>966</span>  * @return {String} URIComponent string such like "%67%68"
<span class='line'>967</span>  * @since 1.1
<span class='line'>968</span>  */</span><span class="WHIT">
<span class='line'>969</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextouricmp</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>970</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/(..)/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"%$1"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>971</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>972</span> 
<span class='line'>973</span> </span><span class="COMM">// ==== hex / ipv6 =================================</span><span class="WHIT">
<span class='line'>974</span> 
<span class='line'>975</span> </span><span class="COMM">/**
<span class='line'>976</span>  * convert any IPv6 address to a 16 byte hexadecimal string
<span class='line'>977</span>  * @function
<span class='line'>978</span>  * @param s string of IPv6 address
<span class='line'>979</span>  * @return {String} 16 byte hexadecimal string of IPv6 address
<span class='line'>980</span>  * @description
<span class='line'>981</span>  * This function converts any IPv6 address representation string
<span class='line'>982</span>  * to a 16 byte hexadecimal string of address.
<span class='line'>983</span>  * @example
<span class='line'>984</span>  * 
<span class='line'>985</span>  */</span><span class="WHIT">
<span class='line'>986</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ipv6tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>987</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">msgMalformedAddress</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"malformed IPv6 address"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>988</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Fa-f:]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>989</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">msgMalformedAddress</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>990</span> 
<span class='line'>991</span> </span><span class="WHIT">  </span><span class="COMM">// 1. downcase</span><span class="WHIT">
<span class='line'>992</span> </span><span class="WHIT">  </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>993</span> 
<span class='line'>994</span> </span><span class="WHIT">  </span><span class="COMM">// 2. expand ::</span><span class="WHIT">
<span class='line'>995</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">num_colon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.split</span><span class="PUNC">(</span><span class="STRN">':'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>996</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">num_colon</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">msgMalformedAddress</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>997</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">colon_replacer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="PUNC">.</span><span class="NAME">repeat</span><span class="PUNC">(</span><span class="NUMB">7</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">num_colon</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>998</span> </span><span class="WHIT">  </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="STRN">'::'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">colon_replacer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>999</span> 
<span class='line'>1000</span> </span><span class="WHIT">  </span><span class="COMM">// 3. fill zero</span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.split</span><span class="PUNC">(</span><span class="STRN">':'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">msgMalformedAddress</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT">    </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1006</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1007</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1008</span> 
<span class='line'>1009</span> </span><span class="COMM">/**
<span class='line'>1010</span>  * convert a 16 byte hexadecimal string to RFC 5952 canonicalized IPv6 address&lt;br/>
<span class='line'>1011</span>  * @name hextoipv6
<span class='line'>1012</span>  * @function
<span class='line'>1013</span>  * @param {String} s hexadecimal string of 16 byte IPv6 address
<span class='line'>1014</span>  * @return {String} IPv6 address string canonicalized by RFC 5952
<span class='line'>1015</span>  * @since jsrsasign 8.0.10 base64x 1.1.13
<span class='line'>1016</span>  * @description
<span class='line'>1017</span>  * This function converts a 16 byte hexadecimal string to 
<span class='line'>1018</span>  * &lt;a href="https://tools.ietf.org/html/rfc5952">RFC 5952&lt;/a>
<span class='line'>1019</span>  * canonicalized IPv6 address string.
<span class='line'>1020</span>  * @example
<span class='line'>1021</span>  * hextoipv6("871020010db8000000000000000000000004") &rarr "2001:db8::4"
<span class='line'>1022</span>  * hextoipv6("871020010db8000000000000000000") &rarr raise exception
<span class='line'>1023</span>  * hextoipv6("xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz") &rarr raise exception
<span class='line'>1024</span>  */</span><span class="WHIT">
<span class='line'>1025</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextoipv6</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1026</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Fa-f]{32}$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1027</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"malformed IPv6 address: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1028</span> 
<span class='line'>1029</span> </span><span class="WHIT">    </span><span class="COMM">// 1. downcase</span><span class="WHIT">
<span class='line'>1030</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1031</span> 
<span class='line'>1032</span> </span><span class="WHIT">    </span><span class="COMM">// 2. split 4 > ["0123", "00a4", "0000", ..., "ffff"]</span><span class="WHIT">
<span class='line'>1033</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/.{1,4}/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1034</span> 
<span class='line'>1035</span> </span><span class="WHIT">    </span><span class="COMM">// 3. trim leading 0 for items and join > "123:a4:0:...:ffff"</span><span class="WHIT">
<span class='line'>1036</span> </span><span class="WHIT">    </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/^0+/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1037</span> </span><span class="WHIT">    </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1038</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">a.join</span><span class="PUNC">(</span><span class="STRN">':'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1039</span> 
<span class='line'>1040</span> </span><span class="WHIT">    </span><span class="COMM">// 4. find shrinkable candidates :0:0:..:0:</span><span class="WHIT">
<span class='line'>1041</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">aZero</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/:(0:){2,}/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1042</span> 
<span class='line'>1043</span> </span><span class="WHIT">    </span><span class="COMM">// 5. no shrinkable</span><span class="WHIT">
<span class='line'>1044</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">aZero</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s.slice</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1045</span> 
<span class='line'>1046</span> </span><span class="WHIT">    </span><span class="COMM">// 6. fix max length zero(:0:...:0:)</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sMaxZero</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aZero.sort</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1048</span> 
<span class='line'>1049</span> </span><span class="WHIT">    </span><span class="COMM">// 7. replace shrinked</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="NAME">sMaxZero.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sMaxZero.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1051</span> 
<span class='line'>1052</span> </span><span class="WHIT">    </span><span class="COMM">// 8. trim leading ':' if not '::'</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'::'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1054</span> 
<span class='line'>1055</span> </span><span class="WHIT">    </span><span class="COMM">// 9. trim tail ':' if not '::'</span><span class="WHIT">
<span class='line'>1056</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'::'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1057</span> 
<span class='line'>1058</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1059</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1060</span> 
<span class='line'>1061</span> </span><span class="COMM">// ==== hex / ip =================================</span><span class="WHIT">
<span class='line'>1062</span> 
<span class='line'>1063</span> </span><span class="COMM">/**
<span class='line'>1064</span>  * convert a hexadecimal string to IP addresss&lt;br/>
<span class='line'>1065</span>  * @name hextoip
<span class='line'>1066</span>  * @function
<span class='line'>1067</span>  * @param {String} s hexadecimal string of IP address
<span class='line'>1068</span>  * @return {String} IP address string
<span class='line'>1069</span>  * @since jsrsasign 8.0.10 base64x 1.1.13
<span class='line'>1070</span>  * @see hextoipv6
<span class='line'>1071</span>  * @see iptohex
<span class='line'>1072</span>  *
<span class='line'>1073</span>  * @description
<span class='line'>1074</span>  * This function converts a hexadecimal string of IPv4 or 
<span class='line'>1075</span>  * IPv6 address to IPv4 or IPv6 address string.
<span class='line'>1076</span>  * If byte length is not 4 nor 16, this returns a
<span class='line'>1077</span>  * hexadecimal string without conversion.
<span class='line'>1078</span>  * &lt;br/>
<span class='line'>1079</span>  * NOTE: From jsrsasign 10.5.17, CIDR subnet mask notation also supported.
<span class='line'>1080</span>  *
<span class='line'>1081</span>  * @example
<span class='line'>1082</span>  * hextoip("c0a80101") &rarr; "192.168.1.1"
<span class='line'>1083</span>  * hextoip("871020010db8000000000000000000000004") &rarr "2001:db8::4"
<span class='line'>1084</span>  * hextoip("c0a80100ffffff00") &rarr; "192.168.1.0/24"
<span class='line'>1085</span>  * hextoip("c0a801010203") &rarr; "c0a801010203" // wrong 6 bytes
<span class='line'>1086</span>  * hextoip("zzz")) &rarr; raise exception because of not hexadecimal
<span class='line'>1087</span>  */</span><span class="WHIT">
<span class='line'>1088</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextoip</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1089</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"malformed hex value"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1090</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1091</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1092</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// ipv4</span><span class="WHIT">
<span class='line'>1093</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ip</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1094</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1095</span> </span><span class="WHIT">	    </span><span class="NAME">ip</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1096</span> </span><span class="WHIT"> 		 </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1097</span> </span><span class="WHIT">		 </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1098</span> </span><span class="WHIT">		 </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1099</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ip</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1100</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1101</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1102</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1103</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1104</span> </span><span class="WHIT">      </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1105</span> </span><span class="WHIT">	  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextoip</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ipprefixlen</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">8</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT">	  </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1110</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextoipv6</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">64</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1112</span> </span><span class="WHIT">      </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1113</span> </span><span class="WHIT">	  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextoipv6</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ipprefixlen</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1114</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1115</span> </span><span class="WHIT">	  </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1116</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1117</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> 
<span class='line'>1118</span>   </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1122</span> 
<span class='line'>1123</span> </span><span class="COMM">/*
<span class='line'>1124</span>  * convert subnet mask hex to ip address prefix length&lt;br/>
<span class='line'>1125</span>  * @name ipprefixlen
<span class='line'>1126</span>  * @param {string} hMask hexadecimal string of ipv4/6 subnet mask (ex. "ffffff00" for v4 class C)
<span class='line'>1127</span>  * @return {nummber} ip address prefix length (ex. 24 for IPv4 class C)
<span class='line'>1128</span>  */</span><span class="WHIT">
<span class='line'>1129</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ipprefixlen</span><span class="PUNC">(</span><span class="NAME">hMask</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1130</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"malformed mask"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1131</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bMask</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1132</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="WHIT">	</span><span class="NAME">bMask</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">hMask</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1134</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1135</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1136</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1137</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">bMask.match</span><span class="PUNC">(</span><span class="REGX">/^1*0*$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1138</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">bMask.replace</span><span class="PUNC">(</span><span class="REGX">/0+$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1139</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1140</span> 
<span class='line'>1141</span> </span><span class="COMM">/**
<span class='line'>1142</span>  * convert IPv4/v6 addresss to a hexadecimal string&lt;br/>
<span class='line'>1143</span>  * @name iptohex
<span class='line'>1144</span>  * @function
<span class='line'>1145</span>  * @param {String} s IPv4/v6 address string
<span class='line'>1146</span>  * @return {String} hexadecimal string of IP address
<span class='line'>1147</span>  * @since jsrsasign 8.0.12 base64x 1.1.14
<span class='line'>1148</span>  * @see hextoip
<span class='line'>1149</span>  * @see ipv6tohex
<span class='line'>1150</span>  *
<span class='line'>1151</span>  * @description
<span class='line'>1152</span>  * This function converts IPv4 or IPv6 address string to
<span class='line'>1153</span>  * a hexadecimal string of IPv4 or IPv6 address.
<span class='line'>1154</span>  * &lt;br/>
<span class='line'>1155</span>  * NOTE: From jsrsasign 10.5.17, CIDR net mask notation also supported.
<span class='line'>1156</span>  *
<span class='line'>1157</span>  * @example
<span class='line'>1158</span>  * iptohex("192.168.1.1") &rarr; "c0a80101"
<span class='line'>1159</span>  * iptohex("2001:db8::4") &rarr; "871020010db8000000000000000000000004"
<span class='line'>1160</span>  * iptohex("192.168.1.1/24") &rarr; "c0a80101ffffff00"
<span class='line'>1161</span>  * iptohex("2001:db8::/120") &rarr; "871020010db8000000000000000000000000ffffffffffffffffffffffffffffffffff00"
<span class='line'>1162</span>  * iptohex("zzz")) &rarr; raise exception
<span class='line'>1163</span>  */</span><span class="WHIT">
<span class='line'>1164</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">iptohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1165</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"malformed IP address"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1166</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.toLowerCase</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1167</span> 
<span class='line'>1168</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-f.:/</span><span class="PUNC">]</span><span class="PUNC">+</span><span class="NAME">$</span><span class="PUNC">/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1169</span> 
<span class='line'>1170</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9.]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1171</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.split</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1172</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1174</span> </span><span class="WHIT">	</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1175</span> </span><span class="WHIT">	    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1176</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1177</span> </span><span class="WHIT">		</span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1178</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1179</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1180</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1181</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1182</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1183</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9.]+\/[0-9]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1184</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">aItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.split</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1185</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">iptohex</span><span class="PUNC">(</span><span class="NAME">aItem</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ipnetmask</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">aItem</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1186</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-f:]+$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">s.indexOf</span><span class="PUNC">(</span><span class="STRN">":"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1187</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ipv6tohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1188</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-f:]+\/[0-9]+$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">s.indexOf</span><span class="PUNC">(</span><span class="STRN">":"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1189</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">aItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.split</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1190</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ipv6tohex</span><span class="PUNC">(</span><span class="NAME">aItem</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ipnetmask</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">aItem</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">128</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1191</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">malformedErr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1193</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1194</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1195</span> 
<span class='line'>1196</span> </span><span class="COMM">/*
<span class='line'>1197</span>  * convert ip prefix length to net mask octets&lt;br/>
<span class='line'>1198</span>  * @param {number} prefixlen ip prefix length value (ex. 24 for IPv4 class C)
<span class='line'>1199</span>  * @param {number} len ip address length (ex. 32 for IPv4 and 128 for IPv6)
<span class='line'>1200</span>  * @return {string} hexadecimal string of net mask octets
<span class='line'>1201</span>  * @example
<span class='line'>1202</span>  * ipnetmask(24, 32) &rarr; "ffffff00" 
<span class='line'>1203</span>  * ipnetmask(120, 128) &rarr; "ffffffffffffffffffffffffffffff00"
<span class='line'>1204</span>  */</span><span class="WHIT">
<span class='line'>1205</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ipnetmask</span><span class="PUNC">(</span><span class="NAME">prefixlen</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1206</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">prefixlen</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"00000000"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// v4</span><span class="WHIT">
<span class='line'>1207</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">128</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">prefixlen</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"00000000000000000000000000000000"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// v6</span><span class="WHIT">
<span class='line'>1208</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">prefixlen</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">"1"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">prefixlen</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">"0"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1209</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1211</span> 
<span class='line'>1212</span> </span><span class="COMM">// ==== ucs2hex / utf8 ==============================</span><span class="WHIT">
<span class='line'>1213</span> 
<span class='line'>1214</span> </span><span class="COMM">/**
<span class='line'>1215</span>  * convert UCS-2 hexadecimal stirng to UTF-8 string&lt;br/>
<span class='line'>1216</span>  * @name ucs2hextoutf8
<span class='line'>1217</span>  * @function
<span class='line'>1218</span>  * @param {String} s hexadecimal string of UCS-2 string (ex. "0066")
<span class='line'>1219</span>  * @return {String} UTF-8 string
<span class='line'>1220</span>  * @since jsrsasign 10.1.13 base64x 1.1.20
<span class='line'>1221</span>  * @description
<span class='line'>1222</span>  * This function converts hexadecimal value of UCS-2 string to 
<span class='line'>1223</span>  * UTF-8 string.
<span class='line'>1224</span>  * @example
<span class='line'>1225</span>  * ucs2hextoutf8("006600fc0072") &rarr "für"
<span class='line'>1226</span>  */</span><span class="WHIT">
<span class='line'>1227</span> </span><span class="COMM">/*
<span class='line'>1228</span> See: http://nomenclator.la.coocan.jp/unicode/ucs_utf.htm
<span class='line'>1229</span> UCS-2 to UTF-8
<span class='line'>1230</span> UCS-2 code point | UCS-2 bytes       | UTF-8 bytes
<span class='line'>1231</span> U+0000 .. U+007F | 00000000-0xxxxxxx | 0xxxxxxx (1 byte)
<span class='line'>1232</span> U+0080 .. U+07FF | 00000xxx-xxyyyyyy | 110xxxxx 10yyyyyy (2 byte)
<span class='line'>1233</span> U+0800 .. U+FFFF | xxxxyyyy-yyzzzzzz | 1110xxxx 10yyyyyy 10zzzzzz (3 byte)
<span class='line'>1234</span>  */</span><span class="WHIT">
<span class='line'>1235</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ucs2hextoutf8</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">_conv</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1237</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1238</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1239</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i1</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NAME">i2</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0x80</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// 1 byte</span><span class="WHIT">
<span class='line'>1240</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">i2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1241</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1242</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i1</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// 2 bytes</span><span class="WHIT">
<span class='line'>1243</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0xc0</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">i1</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x07</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">i2</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xc0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1244</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x80</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i2</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x3f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1245</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextoutf8</span><span class="PUNC">(</span><span class="NAME">u1.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">u2.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1246</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1247</span> </span><span class="WHIT">	</span><span class="COMM">// 3 bytes</span><span class="WHIT">
<span class='line'>1248</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0xe0</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">i1</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xf0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1249</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x80</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">i1</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x0f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">i2</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0xc0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">u3</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0x80</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i2</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x3f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hextoutf8</span><span class="PUNC">(</span><span class="NAME">u1.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">u2.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">u3.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/.{4}/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.map</span><span class="PUNC">(</span><span class="NAME">_conv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1255</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">a2.join</span><span class="PUNC">(</span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1256</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1257</span> 
<span class='line'>1258</span> </span><span class="COMM">// ==== URIComponent ================================</span><span class="WHIT">
<span class='line'>1259</span> </span><span class="COMM">/**
<span class='line'>1260</span>  * convert UTFa hexadecimal string to a URLComponent string such like "%67%68".&lt;br/>
<span class='line'>1261</span>  * Note that these "&lt;code>0-9A-Za-z!'()*-._~&lt;/code>" characters will not
<span class='line'>1262</span>  * converted to "%xx" format by builtin 'encodeURIComponent()' function.
<span class='line'>1263</span>  * However this 'encodeURIComponentAll()' function will convert 
<span class='line'>1264</span>  * all of characters into "%xx" format.
<span class='line'>1265</span>  * @name encodeURIComponentAll
<span class='line'>1266</span>  * @function
<span class='line'>1267</span>  * @param {String} s hexadecimal string
<span class='line'>1268</span>  * @return {String} URIComponent string such like "%67%68"
<span class='line'>1269</span>  * @since 1.1
<span class='line'>1270</span>  */</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">encodeURIComponentAll</span><span class="PUNC">(</span><span class="NAME">u8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1272</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">u8</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1273</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1274</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1275</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"%"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1276</span> </span><span class="WHIT">      </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1277</span> </span><span class="WHIT">      </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1278</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1279</span> </span><span class="WHIT">      </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"%"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">stohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1280</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1281</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1282</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1283</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1284</span> 
<span class='line'>1285</span> </span><span class="COMM">// ==== new lines ================================</span><span class="WHIT">
<span class='line'>1286</span> </span><span class="COMM">/**
<span class='line'>1287</span>  * convert all DOS new line("\r\n") to UNIX new line("\n") in 
<span class='line'>1288</span>  * a String "s".
<span class='line'>1289</span>  * @name newline_toUnix
<span class='line'>1290</span>  * @function
<span class='line'>1291</span>  * @param {String} s string 
<span class='line'>1292</span>  * @return {String} converted string
<span class='line'>1293</span>  */</span><span class="WHIT">
<span class='line'>1294</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">newline_toUnix</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1295</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\r\n/mg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1296</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1297</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1298</span> 
<span class='line'>1299</span> </span><span class="COMM">/**
<span class='line'>1300</span>  * convert all UNIX new line("\r\n") to DOS new line("\n") in 
<span class='line'>1301</span>  * a String "s".
<span class='line'>1302</span>  * @name newline_toDos
<span class='line'>1303</span>  * @function
<span class='line'>1304</span>  * @param {String} s string 
<span class='line'>1305</span>  * @return {String} converted string
<span class='line'>1306</span>  */</span><span class="WHIT">
<span class='line'>1307</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">newline_toDos</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1308</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\r\n/mg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1309</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\n/mg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\r\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1310</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1311</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1312</span> 
<span class='line'>1313</span> </span><span class="COMM">// ==== string type checker ===================</span><span class="WHIT">
<span class='line'>1314</span> 
<span class='line'>1315</span> </span><span class="COMM">/**
<span class='line'>1316</span>  * check whether a string is an integer string or not&lt;br/>
<span class='line'>1317</span>  * @name isInteger
<span class='line'>1318</span>  * @memberOf KJUR.lang.String
<span class='line'>1319</span>  * @function
<span class='line'>1320</span>  * @static
<span class='line'>1321</span>  * @param {String} s input string
<span class='line'>1322</span>  * @return {Boolean} true if a string "s" is an integer string otherwise false
<span class='line'>1323</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'>1324</span>  * @example
<span class='line'>1325</span>  * KJUR.lang.String.isInteger("12345") &rarr; true
<span class='line'>1326</span>  * KJUR.lang.String.isInteger("123ab") &rarr; false
<span class='line'>1327</span>  */</span><span class="WHIT">
<span class='line'>1328</span> </span><span class="NAME">KJUR.lang.String.isInteger</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1329</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1330</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1331</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^-[0-9]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1332</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1333</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1334</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1335</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1336</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1337</span> 
<span class='line'>1338</span> </span><span class="COMM">/**
<span class='line'>1339</span>  * check whether a string is an hexadecimal string or not (DEPRECATED)&lt;br/>
<span class='line'>1340</span>  * @name isHex
<span class='line'>1341</span>  * @memberOf KJUR.lang.String
<span class='line'>1342</span>  * @function
<span class='line'>1343</span>  * @static
<span class='line'>1344</span>  * @param {String} s input string
<span class='line'>1345</span>  * @return {Boolean} true if a string "s" is an hexadecimal string otherwise false
<span class='line'>1346</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'>1347</span>  * @deprecated from 10.0.6. please use {@link ishex}
<span class='line'>1348</span>  * @see ishex
<span class='line'>1349</span>  * @example
<span class='line'>1350</span>  * KJUR.lang.String.isHex("1234") &rarr; true
<span class='line'>1351</span>  * KJUR.lang.String.isHex("12ab") &rarr; true
<span class='line'>1352</span>  * KJUR.lang.String.isHex("12AB") &rarr; true
<span class='line'>1353</span>  * KJUR.lang.String.isHex("12ZY") &rarr; false
<span class='line'>1354</span>  * KJUR.lang.String.isHex("121") &rarr; false -- odd length
<span class='line'>1355</span>  */</span><span class="WHIT">
<span class='line'>1356</span> </span><span class="NAME">KJUR.lang.String.isHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1357</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ishex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1358</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1359</span> 
<span class='line'>1360</span> </span><span class="COMM">/**
<span class='line'>1361</span>  * check whether a string is an hexadecimal string or not&lt;br/>
<span class='line'>1362</span>  * @name ishex
<span class='line'>1363</span>  * @function
<span class='line'>1364</span>  * @static
<span class='line'>1365</span>  * @param {String} s input string
<span class='line'>1366</span>  * @return {Boolean} true if a string "s" is an hexadecimal string otherwise false
<span class='line'>1367</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'>1368</span>  * @example
<span class='line'>1369</span>  * ishex("1234") &rarr; true
<span class='line'>1370</span>  * ishex("12ab") &rarr; true
<span class='line'>1371</span>  * ishex("12AB") &rarr; true
<span class='line'>1372</span>  * ishex("12ZY") &rarr; false
<span class='line'>1373</span>  * ishex("121") &rarr; false -- odd length
<span class='line'>1374</span>  */</span><span class="WHIT">
<span class='line'>1375</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">ishex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1376</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>1377</span> </span><span class="WHIT">	</span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-f]+$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-F]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1378</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1379</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1380</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1381</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1382</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1383</span> 
<span class='line'>1384</span> </span><span class="COMM">/**
<span class='line'>1385</span>  * check whether a string is a base64 encoded string or not&lt;br/>
<span class='line'>1386</span>  * Input string can conclude new lines or space characters.
<span class='line'>1387</span>  * @name isBase64
<span class='line'>1388</span>  * @memberOf KJUR.lang.String
<span class='line'>1389</span>  * @function
<span class='line'>1390</span>  * @static
<span class='line'>1391</span>  * @param {String} s input string
<span class='line'>1392</span>  * @return {Boolean} true if a string "s" is a base64 encoded string otherwise false
<span class='line'>1393</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'>1394</span>  * @example
<span class='line'>1395</span>  * KJUR.lang.String.isBase64("YWE=") &rarr; true
<span class='line'>1396</span>  * KJUR.lang.String.isBase64("YW_=") &rarr; false
<span class='line'>1397</span>  * KJUR.lang.String.isBase64("YWE") &rarr; false -- length shall be multiples of 4
<span class='line'>1398</span>  */</span><span class="WHIT">
<span class='line'>1399</span> </span><span class="NAME">KJUR.lang.String.isBase64</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1400</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1401</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Za-z+\/]+={0,3}$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1402</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1403</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1404</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1405</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1406</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1407</span> 
<span class='line'>1408</span> </span><span class="COMM">/**
<span class='line'>1409</span>  * check whether a string is a base64url encoded string or not&lt;br/>
<span class='line'>1410</span>  * Input string can conclude new lines or space characters.
<span class='line'>1411</span>  * @name isBase64URL
<span class='line'>1412</span>  * @memberOf KJUR.lang.String
<span class='line'>1413</span>  * @function
<span class='line'>1414</span>  * @static
<span class='line'>1415</span>  * @param {String} s input string
<span class='line'>1416</span>  * @return {Boolean} true if a string "s" is a base64url encoded string otherwise false
<span class='line'>1417</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'>1418</span>  * @example
<span class='line'>1419</span>  * KJUR.lang.String.isBase64URL("YWE") &rarr; true
<span class='line'>1420</span>  * KJUR.lang.String.isBase64URL("YW-") &rarr; true
<span class='line'>1421</span>  * KJUR.lang.String.isBase64URL("YW+") &rarr; false
<span class='line'>1422</span>  */</span><span class="WHIT">
<span class='line'>1423</span> </span><span class="NAME">KJUR.lang.String.isBase64URL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1424</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/[+/</span><span class="PUNC">=</span><span class="PUNC">]</span><span class="PUNC">/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1425</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utob64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1426</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">KJUR.lang.String.isBase64</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1427</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1428</span> 
<span class='line'>1429</span> 
<span class='line'>1430</span> </span><span class="COMM">/**
<span class='line'>1431</span>  * check whether a string is a base64url encoded string and dot or not&lt;br/>
<span class='line'>1432</span>  * Input string can conclude new lines or space characters.
<span class='line'>1433</span>  * @name isBase64URLDot
<span class='line'>1434</span>  * @function
<span class='line'>1435</span>  * @static
<span class='line'>1436</span>  * @param {String} s input string
<span class='line'>1437</span>  * @return {Boolean} true if a string "s" is a base64url encoded string and dot otherwise false
<span class='line'>1438</span>  * @since base64x 1.1.30 jsrsasign 10.5.25
<span class='line'>1439</span>  * @example
<span class='line'>1440</span>  * isBase64URLDot("YWE") &rarr; true
<span class='line'>1441</span>  * isBase64URLDot("YWE.YWE.YWE") &rarr; true
<span class='line'>1442</span>  * isBase64URLDot("YW-") &rarr; true
<span class='line'>1443</span>  * isBase64URLDot("YW+") &rarr; false
<span class='line'>1444</span>  */</span><span class="WHIT">
<span class='line'>1445</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isBase64URLDot</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1446</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Za-z-_.]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1447</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1448</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1449</span> 
<span class='line'>1450</span> </span><span class="COMM">/**
<span class='line'>1451</span>  * check whether a string is a string of integer array or not&lt;br/>
<span class='line'>1452</span>  * Input string can conclude new lines or space characters.
<span class='line'>1453</span>  * @name isIntegerArray
<span class='line'>1454</span>  * @memberOf KJUR.lang.String
<span class='line'>1455</span>  * @function
<span class='line'>1456</span>  * @static
<span class='line'>1457</span>  * @param {String} s input string
<span class='line'>1458</span>  * @return {Boolean} true if a string "s" is a string of integer array otherwise false
<span class='line'>1459</span>  * @since base64x 1.1.7 jsrsasign 5.0.13
<span class='line'>1460</span>  * @example
<span class='line'>1461</span>  * KJUR.lang.String.isIntegerArray("[1,2,3]") &rarr; true
<span class='line'>1462</span>  * KJUR.lang.String.isIntegerArray("  [1, 2, 3  ] ") &rarr; true
<span class='line'>1463</span>  * KJUR.lang.String.isIntegerArray("[a,2]") &rarr; false
<span class='line'>1464</span>  */</span><span class="WHIT">
<span class='line'>1465</span> </span><span class="NAME">KJUR.lang.String.isIntegerArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1466</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1467</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^\[[0-9,]+\]$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1468</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1469</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1470</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1471</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1472</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1473</span> 
<span class='line'>1474</span> </span><span class="COMM">/**
<span class='line'>1475</span>  * check whether a string consists of PrintableString characters&lt;br/>
<span class='line'>1476</span>  * @name isPrintable
<span class='line'>1477</span>  * @memberOf KJUR.lang.String
<span class='line'>1478</span>  * @function
<span class='line'>1479</span>  * @static
<span class='line'>1480</span>  * @param {String} s input string
<span class='line'>1481</span>  * @return {Boolean} true if a string "s" consists of PrintableString characters
<span class='line'>1482</span>  * @since jsrsasign 9.0.0 base64x 1.1.16
<span class='line'>1483</span>  * A PrintableString consists of following characters
<span class='line'>1484</span>  * &lt;pre>
<span class='line'>1485</span>  * 0-9A-Za-z '()+,-./:=?
<span class='line'>1486</span>  * &lt;/pre>
<span class='line'>1487</span>  * This method returns false when other characters than above.
<span class='line'>1488</span>  * Otherwise it returns true.
<span class='line'>1489</span>  * @example
<span class='line'>1490</span>  * KJUR.lang.String.isPrintable("abc") &rarr; true
<span class='line'>1491</span>  * KJUR.lang.String.isPrintable("abc@") &rarr; false
<span class='line'>1492</span>  * KJUR.lang.String.isPrintable("あいう") &rarr; false
<span class='line'>1493</span>  */</span><span class="WHIT">
<span class='line'>1494</span> </span><span class="NAME">KJUR.lang.String.isPrintable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1495</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9A-Za-z '()+,-./</span><span class="PUNC">:</span><span class="PUNC">=</span><span class="PUNC">?</span><span class="PUNC">]</span><span class="PUNC">*</span><span class="NAME">$</span><span class="PUNC">/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1496</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1497</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1498</span> 
<span class='line'>1499</span> </span><span class="COMM">/**
<span class='line'>1500</span>  * check whether a string consists of IAString characters&lt;br/>
<span class='line'>1501</span>  * @name isIA5
<span class='line'>1502</span>  * @memberOf KJUR.lang.String
<span class='line'>1503</span>  * @function
<span class='line'>1504</span>  * @static
<span class='line'>1505</span>  * @param {String} s input string
<span class='line'>1506</span>  * @return {Boolean} true if a string "s" consists of IA5String characters
<span class='line'>1507</span>  * @since jsrsasign 9.0.0 base64x 1.1.16
<span class='line'>1508</span>  * A IA5String consists of following characters
<span class='line'>1509</span>  * &lt;pre>
<span class='line'>1510</span>  * %x00-21/%x23-7F (i.e. ASCII characters excludes double quote(%x22)
<span class='line'>1511</span>  * &lt;/pre>
<span class='line'>1512</span>  * This method returns false when other characters than above.
<span class='line'>1513</span>  * Otherwise it returns true.
<span class='line'>1514</span>  * @example
<span class='line'>1515</span>  * KJUR.lang.String.isIA5("abc") &rarr; true
<span class='line'>1516</span>  * KJUR.lang.String.isIA5('"abc"') &rarr; false
<span class='line'>1517</span>  * KJUR.lang.String.isIA5("あいう") &rarr; false
<span class='line'>1518</span>  */</span><span class="WHIT">
<span class='line'>1519</span> </span><span class="NAME">KJUR.lang.String.isIA5</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1520</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[\x20-\x21\x23-\x7f]*$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1523</span> 
<span class='line'>1524</span> </span><span class="COMM">/**
<span class='line'>1525</span>  * check whether a string is RFC 822 mail address&lt;br/>
<span class='line'>1526</span>  * @name isMail
<span class='line'>1527</span>  * @memberOf KJUR.lang.String
<span class='line'>1528</span>  * @function
<span class='line'>1529</span>  * @static
<span class='line'>1530</span>  * @param {String} s input string
<span class='line'>1531</span>  * @return {Boolean} true if a string "s" RFC 822 mail address
<span class='line'>1532</span>  * @since jsrsasign 9.0.0 base64x 1.1.16
<span class='line'>1533</span>  * This static method will check string s is RFC 822 compliant mail address.
<span class='line'>1534</span>  * @example
<span class='line'>1535</span>  * KJUR.lang.String.isMail("abc") &rarr; false
<span class='line'>1536</span>  * KJUR.lang.String.isMail("abc@example") &rarr; false
<span class='line'>1537</span>  * KJUR.lang.String.isMail("abc@example.com") &rarr; true
<span class='line'>1538</span>  */</span><span class="WHIT">
<span class='line'>1539</span> </span><span class="NAME">KJUR.lang.String.isMail</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1540</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1541</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1542</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1543</span> 
<span class='line'>1544</span> </span><span class="COMM">// ==== others ================================</span><span class="WHIT">
<span class='line'>1545</span> 
<span class='line'>1546</span> </span><span class="COMM">/**
<span class='line'>1547</span>  * canonicalize hexadecimal string of positive integer&lt;br/>
<span class='line'>1548</span>  * @name hextoposhex
<span class='line'>1549</span>  * @function
<span class='line'>1550</span>  * @param {String} s hexadecimal string 
<span class='line'>1551</span>  * @return {String} canonicalized hexadecimal string of positive integer
<span class='line'>1552</span>  * @since base64x 1.1.10 jsrsasign 7.1.4
<span class='line'>1553</span>  * @description
<span class='line'>1554</span>  * This method canonicalize a hexadecimal string of positive integer
<span class='line'>1555</span>  * for two's complement representation.
<span class='line'>1556</span>  * Canonicalized hexadecimal string of positive integer will be:
<span class='line'>1557</span>  * &lt;ul>
<span class='line'>1558</span>  * &lt;li>Its length is always even.&lt;/li>
<span class='line'>1559</span>  * &lt;li>If odd length it will be padded with leading zero.&lt;li>
<span class='line'>1560</span>  * &lt;li>If it is even length and its first character is "8" or greater,
<span class='line'>1561</span>  * it will be padded with "00" to make it positive integer.&lt;/li>
<span class='line'>1562</span>  * &lt;/ul>
<span class='line'>1563</span>  * @example
<span class='line'>1564</span>  * hextoposhex("abcd") &rarr; "00abcd"
<span class='line'>1565</span>  * hextoposhex("1234") &rarr; "1234"
<span class='line'>1566</span>  * hextoposhex("12345") &rarr; "012345"
<span class='line'>1567</span>  */</span><span class="WHIT">
<span class='line'>1568</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextoposhex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1569</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1570</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="STRN">"7"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1571</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1572</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1573</span> 
<span class='line'>1574</span> </span><span class="COMM">/**
<span class='line'>1575</span>  * convert string of integer array to hexadecimal string.&lt;br/>
<span class='line'>1576</span>  * @name intarystrtohex
<span class='line'>1577</span>  * @function
<span class='line'>1578</span>  * @param {String} s string of integer array
<span class='line'>1579</span>  * @return {String} hexadecimal string
<span class='line'>1580</span>  * @since base64x 1.1.6 jsrsasign 5.0.2
<span class='line'>1581</span>  * @throws "malformed integer array string: *" for wrong input
<span class='line'>1582</span>  * @description
<span class='line'>1583</span>  * This function converts a string of JavaScript integer array to
<span class='line'>1584</span>  * a hexadecimal string. Each integer value shall be in a range 
<span class='line'>1585</span>  * from 0 to 255 otherwise it raise exception. Input string can
<span class='line'>1586</span>  * have extra space or newline string so that they will be ignored.
<span class='line'>1587</span>  * 
<span class='line'>1588</span>  * @example
<span class='line'>1589</span>  * intarystrtohex(" [123, 34, 101, 34, 58] ")
<span class='line'>1590</span>  * &rarr; 7b2265223a (i.e. '{"e":' as string)
<span class='line'>1591</span>  */</span><span class="WHIT">
<span class='line'>1592</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">intarystrtohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1593</span> </span><span class="WHIT">  </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/^\s*\[\s*/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1594</span> </span><span class="WHIT">  </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\s*\]\s*$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1595</span> </span><span class="WHIT">  </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.replace</span><span class="PUNC">(</span><span class="REGX">/\s*/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1596</span> </span><span class="WHIT">  </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1597</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.split</span><span class="PUNC">(</span><span class="REGX">/,/</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">map</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">element</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1598</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">element</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1599</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">255</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"integer not in range 0-255"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1600</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hI</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">i.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1601</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hI</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1602</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1603</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1604</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1605</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed integer array string: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ex</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1606</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1607</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1608</span> 
<span class='line'>1609</span> </span><span class="COMM">/**
<span class='line'>1610</span>  * find index of string where two string differs
<span class='line'>1611</span>  * @name strdiffidx
<span class='line'>1612</span>  * @function
<span class='line'>1613</span>  * @param {String} s1 string to compare
<span class='line'>1614</span>  * @param {String} s2 string to compare
<span class='line'>1615</span>  * @return {Number} string index of where character differs. Return -1 if same.
<span class='line'>1616</span>  * @since jsrsasign 4.9.0 base64x 1.1.5
<span class='line'>1617</span>  * @example
<span class='line'>1618</span>  * strdiffidx("abcdefg", "abcd4fg") -> 4
<span class='line'>1619</span>  * strdiffidx("abcdefg", "abcdefg") -> -1
<span class='line'>1620</span>  * strdiffidx("abcdefg", "abcdef") -> 6
<span class='line'>1621</span>  * strdiffidx("abcdefgh", "abcdef") -> 6
<span class='line'>1622</span>  */</span><span class="WHIT">
<span class='line'>1623</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">strdiffidx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1624</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s1.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1625</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s1.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">s2.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s2.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1626</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1627</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s1.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">s2.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1628</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1629</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s1.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">s2.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1630</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// same</span><span class="WHIT">
<span class='line'>1631</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1632</span> 
<span class='line'>1633</span> </span><span class="COMM">// ==== hex / oid =================================</span><span class="WHIT">
<span class='line'>1634</span> 
<span class='line'>1635</span> </span><span class="COMM">/**
<span class='line'>1636</span>  * get hexadecimal value of object identifier from dot noted oid value
<span class='line'>1637</span>  * @name oidtohex
<span class='line'>1638</span>  * @function
<span class='line'>1639</span>  * @param {String} oidString dot noted string of object identifier
<span class='line'>1640</span>  * @return {String} hexadecimal value of object identifier
<span class='line'>1641</span>  * @since jsrsasign 10.1.0 base64x 1.1.18
<span class='line'>1642</span>  * @see hextooid
<span class='line'>1643</span>  * @see ASN1HEX.hextooidstr
<span class='line'>1644</span>  * @see KJUR.asn1.ASN1Util.oidIntToHex
<span class='line'>1645</span>  * @description
<span class='line'>1646</span>  * This static method converts from object identifier value string.
<span class='line'>1647</span>  * to hexadecimal string representation of it.
<span class='line'>1648</span>  * {@link hextooid} is a reverse function of this.
<span class='line'>1649</span>  * @example
<span class='line'>1650</span>  * oidtohex("2.5.4.6") &rarr; "550406"
<span class='line'>1651</span>  */</span><span class="WHIT">
<span class='line'>1652</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">oidtohex</span><span class="PUNC">(</span><span class="NAME">oidString</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1653</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">itox</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1654</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">i.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1655</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1656</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1657</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1658</span> 
<span class='line'>1659</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">roidtox</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">roid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1660</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1661</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">roid</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1662</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bi.toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1663</span> 
<span class='line'>1664</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">padLen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">b.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1665</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">padLen</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">padLen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1666</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bPad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1667</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">padLen</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">bPad</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1668</span> </span><span class="WHIT">        </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bPad</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1669</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">b.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1670</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b8</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1671</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">b.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">b8</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'1'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b8</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1672</span> </span><span class="WHIT">            </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">itox</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">b8</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1673</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1674</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1675</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT">    
<span class='line'>1677</span>     </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">oidString.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9.]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1679</span> </span><span class="WHIT">    
<span class='line'>1680</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oidString.split</span><span class="PUNC">(</span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1682</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i0</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">40</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1683</span> </span><span class="WHIT">	</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">itox</span><span class="PUNC">(</span><span class="NAME">i0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1684</span> </span><span class="WHIT">	</span><span class="NAME">a.splice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1685</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1686</span> </span><span class="WHIT">            </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">roidtox</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1687</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1690</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1691</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1692</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1693</span> 
<span class='line'>1694</span> </span><span class="COMM">/**
<span class='line'>1695</span>  * get oid string from hexadecimal value of object identifier&lt;br/>
<span class='line'>1696</span>  * @name hextooid
<span class='line'>1697</span>  * @function
<span class='line'>1698</span>  * @param {String} h hexadecimal value of object identifier
<span class='line'>1699</span>  * @return {String} dot noted string of object identifier (ex. "1.2.3.4")
<span class='line'>1700</span>  * @since jsrsasign 10.1.0 base64x 1.1.18
<span class='line'>1701</span>  * @see oidtohex
<span class='line'>1702</span>  * @see ASN1HEX.hextooidstr
<span class='line'>1703</span>  * @see KJUR.asn1.ASN1Util.oidIntToHex
<span class='line'>1704</span>  * @description
<span class='line'>1705</span>  * This static method converts from hexadecimal object identifier value 
<span class='line'>1706</span>  * to dot noted OID value (ex. "1.2.3.4").
<span class='line'>1707</span>  * {@link oidtohex} is a reverse function of this.
<span class='line'>1708</span>  * @example
<span class='line'>1709</span>  * hextooid("550406") &rarr; "2.5.4.6"
<span class='line'>1710</span>  */</span><span class="WHIT">
<span class='line'>1711</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">hextooid</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1712</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">ishex</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1713</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1714</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1715</span> 
<span class='line'>1716</span> </span><span class="WHIT">	</span><span class="COMM">// a[0], a[1]</span><span class="WHIT">
<span class='line'>1717</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex0</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1718</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i0</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">hex0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1719</span> </span><span class="WHIT">	</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">i0</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">40</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1720</span> </span><span class="WHIT">	</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">i0</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">40</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1721</span> 
<span class='line'>1722</span> </span><span class="WHIT">	</span><span class="COMM">// a[2]..a[n]</span><span class="WHIT">
<span class='line'>1723</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hex1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1724</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1725</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">hex1.length</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1726</span> </span><span class="WHIT">	    </span><span class="NAME">b.push</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">hex1.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1727</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1728</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1729</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cbin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1730</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">b.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1731</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x80</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1732</span> </span><span class="WHIT">		</span><span class="NAME">cbin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cbin</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">strpad</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x7f</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1733</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1734</span> </span><span class="WHIT">		</span><span class="NAME">cbin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cbin</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">strpad</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x7f</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1735</span> </span><span class="WHIT">		</span><span class="NAME">c.push</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">cbin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1736</span> </span><span class="WHIT">		</span><span class="NAME">cbin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1737</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1738</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1739</span> 
<span class='line'>1740</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.join</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1741</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">c.join</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1742</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1743</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1745</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1747</span> 
<span class='line'>1748</span> </span><span class="COMM">// ==== int / hex =================================</span><span class="WHIT">
<span class='line'>1749</span> </span><span class="COMM">/**
<span class='line'>1750</span>  * get hexadecimal string of minimum two's complement of integer&lt;br/>
<span class='line'>1751</span>  * @name inttohex
<span class='line'>1752</span>  * @function
<span class='line'>1753</span>  * @param {number} i integer value
<span class='line'>1754</span>  * @return {string} hexadecimal string of two's complement of the integer
<span class='line'>1755</span>  * @since jsrsasign 10.9.0 base64x 1.1.34
<span class='line'>1756</span>  * @see twoscompl
<span class='line'>1757</span>  * @see DERInteger
<span class='line'>1758</span>  *
<span class='line'>1759</span>  * @description
<span class='line'>1760</span>  * This static method converts from integer value to a minimum length 
<span class='line'>1761</span>  * hexadecimal string of two's complement of the integer.
<span class='line'>1762</span>  * This method is useful for {@link DERInteger}.
<span class='line'>1763</span>  *
<span class='line'>1764</span>  * @example
<span class='line'>1765</span>  * inttohex(1) &rarr; "01"
<span class='line'>1766</span>  * inttohex(-1) &rarr; "ff"
<span class='line'>1767</span>  * inttohex(2048) &rarr; "0800"
<span class='line'>1768</span>  * inttohex(-2048) &rarr; "f800"
<span class='line'>1769</span>  */</span><span class="WHIT">
<span class='line'>1770</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">inttohex</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1771</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1772</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">twoscompl</span><span class="PUNC">(</span><span class="NAME">bi</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1773</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1774</span> 
<span class='line'>1775</span> </span><span class="COMM">/**
<span class='line'>1776</span>  * get hexadecimal string of minimum two's complement of BigInteger&lt;br/>
<span class='line'>1777</span>  * @name twoscompl
<span class='line'>1778</span>  * @function
<span class='line'>1779</span>  * @param {BigInteger} bi BigInteger object
<span class='line'>1780</span>  * @return {string} hexadecimal string of two's complement of the integer
<span class='line'>1781</span>  * @since jsrsasign 10.9.0 base64x 1.1.34
<span class='line'>1782</span>  * @see inttohex
<span class='line'>1783</span>  *
<span class='line'>1784</span>  * @description
<span class='line'>1785</span>  * This static method converts from a BigInteger object to a minimum length
<span class='line'>1786</span>  * hexadecimal string of two's complement of the integer.
<span class='line'>1787</span>  * &lt;br/>
<span class='line'>1788</span>  * NOTE: This function is a replacement of deprecated ASN1Util.bigIntToMinTwosComplementsHex method.
<span class='line'>1789</span>  *
<span class='line'>1790</span>  * @example
<span class='line'>1791</span>  * twoscompl(new BigInteger("1", 10)) &rarr; "01"
<span class='line'>1792</span>  * twoscompl(new BigInteger("-1", 10)) &rarr; "ff"
<span class='line'>1793</span>  */</span><span class="WHIT">
<span class='line'>1794</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">twoscompl</span><span class="PUNC">(</span><span class="NAME">bi</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1795</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bi.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1796</span> </span><span class="WHIT">    </span><span class="COMM">// positive</span><span class="WHIT">
<span class='line'>1797</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1798</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1799</span> </span><span class="WHIT">	    </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1800</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1801</span> </span><span class="WHIT">	    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">h.match</span><span class="PUNC">(</span><span class="REGX">/^[0-7]/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1802</span> </span><span class="WHIT">		</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'00'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1803</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1804</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1805</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1806</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1807</span> </span><span class="WHIT">    </span><span class="COMM">// negative</span><span class="WHIT">
<span class='line'>1808</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1809</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">xorLen</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hPos.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1810</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">xorLen</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1811</span> </span><span class="WHIT">        </span><span class="NAME">xorLen</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1812</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1813</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">h.match</span><span class="PUNC">(</span><span class="REGX">/^[0-7]/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1814</span> </span><span class="WHIT">            </span><span class="NAME">xorLen</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1815</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1816</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1817</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hMask</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1818</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">xorLen</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1819</span> </span><span class="WHIT">        </span><span class="NAME">hMask</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1820</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1821</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biMask</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BigInteger</span><span class="PUNC">(</span><span class="NAME">hMask</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1822</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biNeg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">biMask.xor</span><span class="PUNC">(</span><span class="NAME">bi</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">add</span><span class="PUNC">(</span><span class="NAME">BigInteger.ONE</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1823</span> </span><span class="WHIT">    </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">biNeg.toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/^-/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1824</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1825</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1826</span> 
<span class='line'>1827</span> </span><span class="COMM">/**
<span class='line'>1828</span>  * string padding&lt;br/>
<span class='line'>1829</span>  * @name strpad
<span class='line'>1830</span>  * @function
<span class='line'>1831</span>  * @param {String} s input string
<span class='line'>1832</span>  * @param {Number} len output string length
<span class='line'>1833</span>  * @param {String} padchar padding character (default is "0")
<span class='line'>1834</span>  * @return {String} padded string
<span class='line'>1835</span>  * @since jsrsasign 10.1.0 base64x 1.1.18
<span class='line'>1836</span>  * @example
<span class='line'>1837</span>  * strpad("1234", 10, "0") &rarr; "0000001234"
<span class='line'>1838</span>  * strpad("1234", 10, " ") &rarr; "      1234"
<span class='line'>1839</span>  * strpad("1234", 10)      &rarr; "0000001234"
<span class='line'>1840</span>  */</span><span class="WHIT">
<span class='line'>1841</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">strpad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padchar</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1842</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">padchar</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">padchar</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1843</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1844</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="NAME">padchar</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1845</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1846</span> 
<span class='line'>1847</span> </span><span class="COMM">// ==== bitstr hex / int =================================</span><span class="WHIT">
<span class='line'>1848</span> 
<span class='line'>1849</span> </span><span class="COMM">/**
<span class='line'>1850</span>  * convert from hexadecimal string of ASN.1 BitString value with unused bit to integer value&lt;br/>
<span class='line'>1851</span>  * @name bitstrtoint
<span class='line'>1852</span>  * @function
<span class='line'>1853</span>  * @param {String} h hexadecimal string of ASN.1 BitString value with unused bit
<span class='line'>1854</span>  * @return {Number} positive integer value of the BitString
<span class='line'>1855</span>  * @since jsrsasign 10.1.3 base64x 1.1.19
<span class='line'>1856</span>  * @see inttobitstr
<span class='line'>1857</span>  * @see KJUR.asn1.DERBitString
<span class='line'>1858</span>  * @see ASN1HEX.getInt
<span class='line'>1859</span>  * 
<span class='line'>1860</span>  * @description
<span class='line'>1861</span>  * This function converts from hexadecimal string of ASN.1 BitString
<span class='line'>1862</span>  * value with unused bit to its integer value. &lt;br/>
<span class='line'>1863</span>  * When an improper hexadecimal string of BitString value
<span class='line'>1864</span>  * is applied, this returns -1.
<span class='line'>1865</span>  * 
<span class='line'>1866</span>  * @example
<span class='line'>1867</span>  * // "03c8" &rarr; 0xc8 unusedbit=03 &rarr; 11001000b unusedbit=03 &rarr; 11001b &rarr; 25
<span class='line'>1868</span>  * bitstrtoint("03c8") &rarr; 25
<span class='line'>1869</span>  * // "02fff8" &rarr; 0xfff8 unusedbit=02 &rarr; 1111111111111000b unusedbit=02
<span class='line'>1870</span>  * //   11111111111110b &rarr; 16382
<span class='line'>1871</span>  * bitstrtoint("02fff8") &rarr; 16382
<span class='line'>1872</span>  * bitstrtoint("05a0") &rarr; 5 (=101b)
<span class='line'>1873</span>  * bitstrtoint("ff00") &rarr; -1 // for improper BitString value
<span class='line'>1874</span>  * bitstrtoint("05a0").toString(2) &rarr; "101"
<span class='line'>1875</span>  * bitstrtoint("07a080").toString(2) &rarr; "101000001"
<span class='line'>1876</span>  */</span><span class="WHIT">
<span class='line'>1877</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">bitstrtoint</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1878</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>1879</span>     </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1880</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-f]+$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1881</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1882</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hUnusedbit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1883</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hUnusedbit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"00"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1884</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1885</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iUnusedbit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">hUnusedbit</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1886</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">iUnusedbit</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1887</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1888</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">hValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1889</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"00000000"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1890</span> </span><span class="WHIT">	</span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bValue.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">iUnusedbit</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1891</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">bValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1892</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">iValue</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">NaN</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1893</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">iValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1894</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1895</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1896</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1897</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1898</span> 
<span class='line'>1899</span> </span><span class="COMM">/**
<span class='line'>1900</span>  * convert from integer value to hexadecimal string of ASN.1 BitString value with unused bit&lt;br/>
<span class='line'>1901</span>  * @name inttobitstr
<span class='line'>1902</span>  * @function
<span class='line'>1903</span>  * @param {Number} n integer value of ASN.1 BitString
<span class='line'>1904</span>  * @return {String} hexadecimal string of ASN.1 BitString value with unused bit
<span class='line'>1905</span>  * @since jsrsasign 10.1.3 base64x 1.1.19
<span class='line'>1906</span>  * @see bitstrtoint
<span class='line'>1907</span>  * @see KJUR.asn1.DERBitString
<span class='line'>1908</span>  * @see ASN1HEX.getInt
<span class='line'>1909</span>  * 
<span class='line'>1910</span>  * @description
<span class='line'>1911</span>  * This function converts from an integer value to 
<span class='line'>1912</span>  * hexadecimal string of ASN.1 BitString value
<span class='line'>1913</span>  * with unused bit. &lt;br/>
<span class='line'>1914</span>  * When "n" is not non-negative number, this returns null
<span class='line'>1915</span>  * 
<span class='line'>1916</span>  * @example
<span class='line'>1917</span>  * // 25 &rarr; 11001b &rarr; 11001000b unusedbit=03 &rarr; 0xc8 unusedbit=03 &rarr; "03c8"
<span class='line'>1918</span>  * inttobitstr(25) &rarr; "03c8"
<span class='line'>1919</span>  * inttobitstr(-3) &rarr; null
<span class='line'>1920</span>  * inttobitstr("abc") &rarr; null
<span class='line'>1921</span>  * inttobitstr(parseInt("11001", 2)) &rarr; "03c8"
<span class='line'>1922</span>  * inttobitstr(parseInt("101", 2)) &rarr; "05a0"
<span class='line'>1923</span>  * inttobitstr(parseInt("101000001", 2)) &rarr; "07a080"
<span class='line'>1924</span>  */</span><span class="WHIT">
<span class='line'>1925</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">inttobitstr</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1926</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1927</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1928</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1929</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">iUnusedbit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">bValue.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1930</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">iUnusedbit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">iUnusedbit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1931</span> </span><span class="WHIT">    </span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bValue</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">strpad</span><span class="PUNC">(</span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">iUnusedbit</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1932</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">bValue</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1933</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hValue.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">hValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1934</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hUnusedbit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">iUnusedbit</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1935</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hUnusedbit</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1936</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1937</span> 
<span class='line'>1938</span> </span><span class="COMM">// ==== bitstr hex / binary string =======================</span><span class="WHIT">
<span class='line'>1939</span> 
<span class='line'>1940</span> </span><span class="COMM">/**
<span class='line'>1941</span>  * convert from hexadecimal string of ASN.1 BitString value with unused bit to binary string&lt;br/>
<span class='line'>1942</span>  * @name bitstrtobinstr
<span class='line'>1943</span>  * @function
<span class='line'>1944</span>  * @param {string} h hexadecimal string of ASN.1 BitString value with unused bit
<span class='line'>1945</span>  * @return {string} binary string
<span class='line'>1946</span>  * @since jsrsasign 10.5.4 base64x 1.1.21
<span class='line'>1947</span>  * @see binstrtobitstr
<span class='line'>1948</span>  * @see inttobitstr
<span class='line'>1949</span>  * 
<span class='line'>1950</span>  * @description
<span class='line'>1951</span>  * This function converts from hexadecimal string of ASN.1 BitString
<span class='line'>1952</span>  * value with unused bit to its integer value. &lt;br/>
<span class='line'>1953</span>  * When an improper hexadecimal string of BitString value
<span class='line'>1954</span>  * is applied, this returns null.
<span class='line'>1955</span>  * 
<span class='line'>1956</span>  * @example
<span class='line'>1957</span>  * bitstrtobinstr("05a0") &rarr; "101"
<span class='line'>1958</span>  * bitstrtobinstr("0520") &rarr; "001"
<span class='line'>1959</span>  * bitstrtobinstr("07a080") &rarr; "101000001"
<span class='line'>1960</span>  * bitstrtobinstr(502) &rarr; null // non ASN.1 BitString value
<span class='line'>1961</span>  * bitstrtobinstr("ff00") &rarr; null // for improper BitString value
<span class='line'>1962</span>  */</span><span class="WHIT">
<span class='line'>1963</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">bitstrtobinstr</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1964</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1965</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1966</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">h.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9a-f]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1967</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1968</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">unusedBits</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1969</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">unusedBits</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">unusedBits</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT">
<span class='line'>1970</span> 
<span class='line'>1971</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">h.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1972</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1973</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">value.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1974</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value.substr</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1975</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">hi</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1976</span> </span><span class="WHIT">	    </span><span class="NAME">bi</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">bi</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">8</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1977</span> </span><span class="WHIT">	    </span><span class="NAME">bin</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bi</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1978</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1979</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT">  </span><span class="NAME">bin.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bin.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">unusedBits</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1980</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1981</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1982</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1983</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1984</span> 
<span class='line'>1985</span> </span><span class="COMM">/**
<span class='line'>1986</span>  * convert from binary string to hexadecimal string of ASN.1 BitString value with unused bit&lt;br/>
<span class='line'>1987</span>  * @name binstrtobitstr
<span class='line'>1988</span>  * @function
<span class='line'>1989</span>  * @param {string} s binary string (ex. "101")
<span class='line'>1990</span>  * @return {string} hexadecimal string of ASN.1 BitString value with unused bit
<span class='line'>1991</span>  * @since jsrsasign 10.5.4 base64x 1.1.21
<span class='line'>1992</span>  * @see bitstrtobinstr
<span class='line'>1993</span>  * @see inttobitstr
<span class='line'>1994</span>  * @see KJUR.asn1.DERBitString
<span class='line'>1995</span>  * 
<span class='line'>1996</span>  * @description
<span class='line'>1997</span>  * This function converts from an binary string (ex. "101") to 
<span class='line'>1998</span>  * hexadecimal string of ASN.1 BitString value
<span class='line'>1999</span>  * with unused bit (ex. "05a0"). &lt;br/>
<span class='line'>2000</span>  * When "s" is not binary string, this returns null.
<span class='line'>2001</span>  * 
<span class='line'>2002</span>  * @example
<span class='line'>2003</span>  * binstrtobitstr("101") &rarr; "05a0"
<span class='line'>2004</span>  * binstrtobitstr("001") &rarr; "0520"
<span class='line'>2005</span>  * binstrtobitstr("11001") &rarr; "03c8"
<span class='line'>2006</span>  * binstrtobitstr("101000001") &rarr; "07a080"
<span class='line'>2007</span>  * binstrtobitstr(101) &rarr; null // not number
<span class='line'>2008</span>  * binstrtobitstr("xyz") &rarr; null // not binary string
<span class='line'>2009</span>  */</span><span class="WHIT">
<span class='line'>2010</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">binstrtobitstr</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2011</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2012</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[01]+$/</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2013</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2014</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2015</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">inttobitstr</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2016</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2017</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2018</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2019</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2020</span> 
<span class='line'>2021</span> </span><span class="COMM">// =======================================================</span><span class="WHIT">
<span class='line'>2022</span> </span><span class="COMM">/**
<span class='line'>2023</span>  * convert array of names to bit string&lt;br/>
<span class='line'>2024</span>  * @name namearraytobinstr
<span class='line'>2025</span>  * @function
<span class='line'>2026</span>  * @param {array} namearray array of name string
<span class='line'>2027</span>  * @param {object} namedb associative array of name and value
<span class='line'>2028</span>  * @return {string} binary string (ex. "110001")
<span class='line'>2029</span>  * @since jsrsasign 10.5.21 base64x 1.1.27
<span class='line'>2030</span>  * @see KJUR.asn1.x509.KeyUsage
<span class='line'>2031</span>  * @see KJUR.asn1.tsp.PKIFailureInfo
<span class='line'>2032</span>  * 
<span class='line'>2033</span>  * @description
<span class='line'>2034</span>  * This function converts from an array of names to
<span class='line'>2035</span>  * a binary string. DB value bit will be set.
<span class='line'>2036</span>  * Note that ordering of namearray items
<span class='line'>2037</span>  * will be ignored.
<span class='line'>2038</span>  *
<span class='line'>2039</span>  * @example
<span class='line'>2040</span>  * db = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
<span class='line'>2041</span>  * namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1000000011'
<span class='line'>2042</span>  * namearraytobinstr(['c', 'b'], db) &rarr: '000100001'
<span class='line'>2043</span>  */</span><span class="WHIT">
<span class='line'>2044</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">namearraytobinstr</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">namearray</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">namedb</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2045</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2046</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">namearray.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2047</span> </span><span class="WHIT">	</span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NAME">namedb</span><span class="PUNC">[</span><span class="NAME">namearray</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2048</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2049</span> 
<span class='line'>2050</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.toString</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2051</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2052</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2053</span> </span><span class="WHIT">	</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2054</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2055</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2056</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2057</span> 
<span class='line'>2058</span> </span><span class="COMM">/**
<span class='line'>2059</span>  * get value of array by key name list&lt;br/>
<span class='line'>2060</span>  * @function
<span class='line'>2061</span>  * @param {object} val array of associative array
<span class='line'>2062</span>  * @param {string} keys concatinated key list with dot (ex. 'type.name.0.info')
<span class='line'>2063</span>  * @param {object} def default value if value is not found (OPTIONAL)
<span class='line'>2064</span>  * @return {object} value if found otherwise returns def
<span class='line'>2065</span>  * @since jsrsasign 10.8.0 base64x 1.1.32
<span class='line'>2066</span>  *
<span class='line'>2067</span>  * @description
<span class='line'>2068</span>  * This function returns the value of an array or associative array 
<span class='line'>2069</span>  * which referred by a concatinated key list string.
<span class='line'>2070</span>  * If a value for key is not defined, it returns 'undefined' by default.
<span class='line'>2071</span>  * When an optional argument 'def' is specified and a value for key is
<span class='line'>2072</span>  * not defined, it returns a value of 'def'.
<span class='line'>2073</span>  * 
<span class='line'>2074</span>  * @example
<span class='line'>2075</span>  * let p = {
<span class='line'>2076</span>  *   fruit: apple,
<span class='line'>2077</span>  *   info: [
<span class='line'>2078</span>  *     { toy: 4 },
<span class='line'>2079</span>  *     { pen: 6 }
<span class='line'>2080</span>  *   ]
<span class='line'>2081</span>  * };
<span class='line'>2082</span>  * aryval(p, 'fruit') &rarr "apple"
<span class='line'>2083</span>  * aryval(p, 'info') &rarr [{toy: 4},{pen: 6}]
<span class='line'>2084</span>  * aryval(p, 'info.1') &rarr {pen: 6}
<span class='line'>2085</span>  * aryval(p, 'info.1.pen') &rarr 6
<span class='line'>2086</span>  * aryval(p, 'money.amount') &rarr undefined
<span class='line'>2087</span>  * aryval(p, 'money.amount', null) &rarr null
<span class='line'>2088</span>  */</span><span class="WHIT">
<span class='line'>2089</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">aryval</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">def</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2090</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT">
<span class='line'>2091</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">keys</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">'.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2092</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">keys.length</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2093</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2094</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2095</span> </span><span class="WHIT">        </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2096</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2097</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">val</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">def</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2098</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2099</span> 
<span class='line'>2100</span> 
<span class='line'>2101</span> </span><span class="COMM">// =======================================================</span><span class="WHIT">
<span class='line'>2102</span> </span><span class="COMM">/**
<span class='line'>2103</span>  * set class inheritance&lt;br/>
<span class='line'>2104</span>  * @name extendClass
<span class='line'>2105</span>  * @function
<span class='line'>2106</span>  * @param {Function} subClass sub class to set inheritance
<span class='line'>2107</span>  * @param {Function} superClass super class to inherit
<span class='line'>2108</span>  * @since jsrsasign 10.3.0 base64x 1.1.21
<span class='line'>2109</span>  *
<span class='line'>2110</span>  * @description
<span class='line'>2111</span>  * This function extends a class and set an inheritance
<span class='line'>2112</span>  * for member variables and methods.
<span class='line'>2113</span>  *
<span class='line'>2114</span>  * @example
<span class='line'>2115</span>  * var Animal = function() {
<span class='line'>2116</span>  *   this.hello = function(){console.log("Hello")};
<span class='line'>2117</span>  *   this.name="Ani";
<span class='line'>2118</span>  * };
<span class='line'>2119</span>  * var Dog = function() {
<span class='line'>2120</span>  *   Dog.superclass.constructor.call(this);
<span class='line'>2121</span>  *   this.vow = function(){console.log("Vow wow")};
<span class='line'>2122</span>  *   this.tail=true;
<span class='line'>2123</span>  * };
<span class='line'>2124</span>  * extendClass(Dog, Animal);
<span class='line'>2125</span>  */</span><span class="WHIT">
<span class='line'>2126</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">extendClass</span><span class="PUNC">(</span><span class="NAME">subClass</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">superClass</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2127</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">F</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2128</span> </span><span class="WHIT">    </span><span class="NAME">F.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">superClass.prototype</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2129</span> </span><span class="WHIT">    </span><span class="NAME">subClass.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">F</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2130</span> </span><span class="WHIT">    </span><span class="NAME">subClass.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">subClass</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2131</span> </span><span class="WHIT">    </span><span class="NAME">subClass.superclass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">superClass.prototype</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2132</span> </span><span class="WHIT">     
<span class='line'>2133</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">superClass.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Object.prototype.constructor</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2134</span> </span><span class="WHIT">        </span><span class="NAME">superClass.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">superClass</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2135</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2136</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2137</span> 
<span class='line'>2138</span> </span></pre></body></html>